mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-02-17 19:01:10 +01:00
Reformat media descriptions which include links to make them clickable
This commit is contained in:
parent
b08d493823
commit
f6318be652
@ -100,6 +100,10 @@ export default function ViewerInfoContent(props) {
|
||||
const { userCan } = useUser();
|
||||
|
||||
const description = props.description.trim();
|
||||
const encoder = document.createElement("div");
|
||||
encoder.appendChild(document.createTextNode(description));
|
||||
const descriptionHTML = encoder.innerHTML;
|
||||
const descriptionHTMLWithLinks = descriptionHTML.replace(/http(s?):\/\/[^\s]+/g, (match) => { return "<a href=\"" + encodeURI(match) + "\" target=\"_blank\" rel=\"nofollow\">" + match + "</a>" });
|
||||
const tagsContent =
|
||||
!PageStore.get('config-enabled').taxonomies.tags || PageStore.get('config-enabled').taxonomies.tags.enabled
|
||||
? metafield(MediaPageStore.get('media-tags'))
|
||||
@ -186,7 +190,7 @@ export default function ViewerInfoContent(props) {
|
||||
PageStore.get('config-options').pages.media.htmlInDescription ? (
|
||||
<div className="media-content-description" dangerouslySetInnerHTML={{ __html: description }}></div>
|
||||
) : (
|
||||
<div className="media-content-description">{description}</div>
|
||||
<div className="media-content-description" dangerouslySetInnerHTML={{ __html: descriptionHTMLWithLinks }}></div>
|
||||
)
|
||||
) : null}
|
||||
{hasSummary ? (
|
||||
|
Loading…
Reference in New Issue
Block a user