diff --git a/src/pages/newsArticle.tsx b/src/pages/newsArticle.tsx index 6f190a2..284ebb0 100644 --- a/src/pages/newsArticle.tsx +++ b/src/pages/newsArticle.tsx @@ -14,7 +14,7 @@ export default function NewsArticle() { sanity.fetch('*[_id == $articleId] [0]', { articleId }).then(setArticle); }, [articleId]); - let thumbUrl: string | null = null; + let thumbUrl: string; if (article?.thumbnail) { thumbUrl = imageUrl(article.thumbnail).url(); } else { @@ -36,7 +36,21 @@ export default function NewsArticle() {
{/* Wrap the BlockContent in a div because it expands to <> */} -
+
{ + /* + When this element loads, convert all the links to have target="_blank." + This ensures that the links open in a new tab + */ + if (ref) { + ref.querySelectorAll('a').forEach((link) => { + link.target = '_blank'; + }); + } + }} + >