From 977defc169da05cab78edd3fc2956d201aada3d1 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Sun, 29 Dec 2024 14:27:16 +0100 Subject: [PATCH] feat: :sparkles: Ensure external links open in a new tab --- plugins/EmojiRenderer.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/EmojiRenderer.ts b/plugins/EmojiRenderer.ts index 83a8ace..7a77154 100644 --- a/plugins/EmojiRenderer.ts +++ b/plugins/EmojiRenderer.ts @@ -44,6 +44,14 @@ export default defineNuxtPlugin((nuxtApp) => { return `${match}`; }); } + + // 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"; + } + } }, }); });