Recognize link in whitin a post
This commit is contained in:
@@ -6,6 +6,10 @@ import { push } from 'react-router-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import moment from 'moment'
|
||||
import { createAction as action } from 'redux-actions'
|
||||
import Linkify from 'react-linkify'
|
||||
|
||||
|
||||
// - Material UI
|
||||
import { Card, CardActions, CardHeader, CardMedia, CardTitle, CardText } from 'material-ui/Card'
|
||||
import FloatingActionButton from 'material-ui/FloatingActionButton'
|
||||
import SvgShare from 'material-ui/svg-icons/social/share'
|
||||
@@ -370,21 +374,24 @@ static propTypes = {
|
||||
|
||||
|
||||
<CardText style={styles.postBody}>
|
||||
{reactStringReplace(body,/#(\w+)/g, (match, i) => (
|
||||
<NavLink
|
||||
style={{color:'green'}}
|
||||
key={match + i}
|
||||
to={`/tag/${match}`}
|
||||
onClick ={evt => {
|
||||
evt.preventDefault()
|
||||
goTo(`/tag/${match}`)
|
||||
setHomeTitle(`#${match}`)
|
||||
}}
|
||||
>
|
||||
#{match}
|
||||
</NavLink>
|
||||
<Linkify properties={{target: '_blank', style: {color: 'blue'}}}>
|
||||
{reactStringReplace(body,/#(\w+)/g, (match, i) => (
|
||||
<NavLink
|
||||
style={{color:'green'}}
|
||||
key={match + i}
|
||||
to={`/tag/${match}`}
|
||||
onClick ={evt => {
|
||||
evt.preventDefault()
|
||||
goTo(`/tag/${match}`)
|
||||
setHomeTitle(`#${match}`)
|
||||
}}
|
||||
>
|
||||
#{match}
|
||||
|
||||
</NavLink>
|
||||
|
||||
))}
|
||||
))}
|
||||
</Linkify>
|
||||
</CardText>
|
||||
<CardActions>
|
||||
<div style={{ margin: "16px 8px", display: 'flex', justifyContent: 'space-between' }}>
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"react-avatar-editor": "^9.1.1",
|
||||
"react-dom": "^15.4.2",
|
||||
"react-event-listener": "^0.4.5",
|
||||
"react-linkify": "^0.2.1",
|
||||
"react-parallax": "^1.4.1",
|
||||
"react-redux": "^5.0.4",
|
||||
"react-router": "^4.1.1 ",
|
||||
|
||||
Reference in New Issue
Block a user