feat: add option to open navbar links in new tab

This commit is contained in:
草师傅 2025-07-22 11:01:13 +08:00
parent d8bf0e69a0
commit 3401ad19a4
Signed by: gb
GPG key ID: 43330A030E2D6478
2 changed files with 4 additions and 4 deletions

View file

@ -5,5 +5,5 @@ const navBarItems = siteConfig.navBarItems
<nav class="nav">
<a href="/" class="home">~</a>
<a href="/blog">Blog</a>
{navBarItems.map((item) => <a href={item.link}>{item.text}</a>)}
{navBarItems.map((item) => <a href={item.link} target={item.openInNewTab !== false ? "_blank" : undefined}>{item.text}</a>)}
</nav>

View file

@ -20,9 +20,9 @@ export const siteConfig = {
navBarItems: [
// additional items in the navbar
// the order of the items will be the same as the order in the array
// format is { text: string, link: string }
{ text: "RSS", link: "/rss.xml" },
{ text: "GitHub", link: "https://github.com/GrassBlock1/mercury" },
// format is { text: string, link: string, openInNewTab?: boolean (default: true) }
{ text: "RSS", link: "/rss.xml", openInNewTab: true },
{ text: "GitHub", link: "https://github.com/GrassBlock1/mercury", openInNewTab: false },
],
// search
// This only works when noClientJavaScript is enabled