Skip to content
Merged
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
17 changes: 17 additions & 0 deletions src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,22 @@ const canonical = new URL(Astro.url.pathname, Astro.site);
</nav>
</div>
</footer>

<script>
// Open external links (different origin) in a new tab. Covers the Visit
// action, footer links, and links inside rendered tool descriptions.
for (const a of document.querySelectorAll<HTMLAnchorElement>('a[href]')) {
const href = a.getAttribute('href');
if (!href) continue;
try {
if (new URL(href, location.href).origin !== location.origin) {
a.target = '_blank';
a.rel = 'noopener noreferrer';
}
} catch {
/* ignore malformed hrefs */
}
}
</script>
</body>
</html>
Loading