Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat media descriptions which include links to make them clickable #570

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Reformat media descriptions which include links to make them clickable
KyleMaas committed Nov 14, 2022
commit f6318be6523433a83ef2374875c994c636a2dc41
Original file line number Diff line number Diff line change
@@ -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 ? (