Don't open mailto: and internal links in a new tab

target="_blank" on mailto: links leaves an empty tab behind. In blog
posts, only links to other sites now open in a new tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
leanderandClaude Opus 5.5 committed 2026-10-30 22:56:08 +01:00
1 parent 70ba50c515
commit 67641c5719
2 files changed
+6 -5

No files matched your search

+5 -2
View File
@@ -102,12 +102,15 @@ const components: PortableTextComponents = {
const href = getSafeHref(value?.href)
if (!href) return <>{children}</>
// Only links to other sites open in a new tab, not mailto: or links
// within this site
const isExternal = /^https?:\/\//i.test(href)
return (
<a
href={href}
target="_blank"
rel="noopener noreferrer"
className={styles.link}
{...(isExternal && { target: "_blank", rel: "noopener noreferrer" })}
>
{children}
</a>
+1 -3
View File
@@ -22,9 +22,7 @@ const Contact = () => {
<div className={styles.container}>
<div className={styles.item}>
<FaAt />
<a href="mailto:styret@uiogaming.no" target="_blank" rel="noreferrer">
{t("email")}
</a>
<a href="mailto:styret@uiogaming.no">{t("email")}</a>
</div>
<div className={styles.item}>
<FaDiscord />