feat: blank config for nav button

This commit is contained in:
HPCesia 2025-04-04 23:01:36 +08:00
parent 01a23952ac
commit e4c27947d7
4 changed files with 38 additions and 5 deletions

View File

@ -43,7 +43,11 @@ if (!title) title = 'Astral Halo';
<ul class="menu bg-base-200/50 absolute -translate-x-[50%] rounded-xl shadow backdrop-blur-md">
{item.items.map((subItem) => (
<Button
{...('href' in subItem && subItem.href && { href: subItem.href })}
{...('href' in subItem &&
subItem.href && {
href: subItem.href,
target: subItem.blank ? '_blank' : undefined,
})}
title={i18n(subItem.text)}
class="btn-ghost btn-primary rounded-field"
>
@ -57,7 +61,11 @@ if (!title) title = 'Astral Halo';
} else {
return (
<Button
{...('href' in item && item.href && { href: item.href })}
{...('href' in item &&
item.href && {
href: item.href,
target: item.blank ? '_blank' : undefined,
})}
title={i18n(item.text)}
class="btn-ghost join-item btn-primary"
>
@ -132,7 +140,11 @@ if (!title) title = 'Astral Halo';
{item.items.map((subItem) => (
<li>
<Button
{...('href' in subItem && subItem.href && { href: subItem.href })}
{...('href' in subItem &&
subItem.href && {
href: subItem.href,
target: subItem.blank ? '_blank' : undefined,
})}
title={i18n(subItem.text)}
class="btn-ghost"
>
@ -148,7 +160,11 @@ if (!title) title = 'Astral Halo';
return (
<li>
<Button
{...('href' in item && item.href && { href: item.href })}
{...('href' in item &&
item.href && {
href: item.href,
target: item.blank ? '_blank' : undefined,
})}
title={i18n(item.text)}
class="btn-ghost"
>

View File

@ -46,7 +46,7 @@ import TocButton from './widgets/SideToolBar/TocButton.vue';
const { icon, text } = item;
if ('href' in item)
return (
<Button href={item.href} title={text}>
<Button href={item.href} target={item.blank ? '_blank' : undefined} title={text}>
<Icon name={icon} slot="icon" />
</Button>
);

View File

@ -106,6 +106,7 @@ export const navbarConfig: NavbarConfig = {
icon: 'material-symbols:rss-feed-rounded',
text: I18nKey.subscribe,
href: '/rss.xml',
blank: true,
},
{
icon: 'material-symbols:casino',

View File

@ -32,6 +32,14 @@ export type ButtonSubConfig<T extends string> = T extends 'text'
* URL
*/
href?: string;
/**
* Whether to open the link in a new tab.
*
*
*
* @default false
*/
blank?: boolean;
}
| {
/**
@ -69,6 +77,14 @@ export type ButtonSubConfig<T extends string> = T extends 'text'
* URL
*/
href?: string;
/**
* Whether to open the link in a new tab.
*
*
*
* @default false
*/
blank?: boolean;
}
| {
/**