feat: Ensure external links open in a new tab

This commit is contained in:
Jesse Wierzbinski 2024-12-29 14:27:16 +01:00
parent 4afe8fc880
commit 977defc169
No known key found for this signature in database

View file

@ -44,6 +44,14 @@ export default defineNuxtPlugin((nuxtApp) => {
return `<img src="/emojis/${emojiFont}/${match}.svg" alt="${match}" class="h-[1em] inline not-prose hover:scale-110 transition-transform duration-75 ease-in-out">`; return `<img src="/emojis/${emojiFont}/${match}.svg" alt="${match}" class="h-[1em] inline not-prose hover:scale-110 transition-transform duration-75 ease-in-out">`;
}); });
} }
// Make all links that don't open to the same origin open in a new tab
for (const link of el.querySelectorAll("a")) {
if (link.hostname !== location.hostname) {
link.target = "_blank";
link.rel = "noopener noreferrer";
}
}
}, },
}); });
}); });