Skip to content
Snippets Groups Projects
Commit 89bef9dd authored by Pomucz Tamás András's avatar Pomucz Tamás András
Browse files

Add link highlighting to news page

parent 4208baad
No related branches found
No related tags found
No related merge requests found
Pipeline #51668 passed
......@@ -10,6 +10,19 @@ import EditNewsForm from '../forms/EditNewsForm';
import { connect } from 'react-redux';
import moment from 'moment';
const linkify = (text) => {
const urlRegex = /(https?:\/\/[^\s]+)/g;
return text.split(urlRegex).map((part, index) =>
part.match(urlRegex) ? (
<a key={index} href={part} target="_blank" rel="noopener noreferrer">
{part}
</a>
) : (
part
)
);
};
class News extends Component {
UNSAFE_componentWillMount() {
this.props.getNews();
......@@ -61,7 +74,7 @@ class News extends Component {
renderMultiLine = (text) => {
const strings = text.split('\n');
return strings.map((string) => <p key={Math.random()}>{string}</p>);
return strings.map((string) => <p key={Math.random()}>{linkify(string)}</p>);
};
render() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment