Commit 0b8cbc7
Changed files (3)
src
components
types
src/components/SideToolBar.astro
@@ -27,6 +27,7 @@ import TocButton from './widgets/SideToolBar/TocButton.vue';
target={item.blank ? '_blank' : undefined}
title={text}
aria-label={text}
+ {...(item.extraAttr || {})}
>
<Icon name={icon} slot="icon" />
</Button>
@@ -34,18 +35,28 @@ import TocButton from './widgets/SideToolBar/TocButton.vue';
if ('onclick' in item) {
if (typeof item.onclick === 'string')
return (
- <Button onclick={item.onclick} title={text} aria-label={text}>
+ <Button
+ onclick={item.onclick}
+ title={text}
+ aria-label={text}
+ {...(item.extraAttr || {})}
+ >
<Icon name={icon} slot="icon" />
</Button>
);
return (
- <Button id={`stb-${item.onclick!.id}`} title={text} aria-label={text}>
+ <Button
+ id={`stb-${item.onclick!.id}`}
+ title={text}
+ aria-label={text}
+ {...(item.extraAttr || {})}
+ >
<Icon name={icon} slot="icon" />
</Button>
);
}
return (
- <Button title={text} aria-label={text}>
+ <Button title={text} aria-label={text} {...(item.extraAttr || {})}>
<Icon name={icon} slot="icon" />
</Button>
);
src/types/config.d.ts
@@ -24,6 +24,12 @@ export type ButtonSubConfig<T extends string> = T extends 'text'
* 按钮的文本。
*/
text: string;
+ /**
+ * Extra attributes add to button HTML tag
+ *
+ * 添加到按钮 HTML 标签上的额外属性
+ */
+ extraAttr?: Record<string, string>;
} & (
| {
/**
@@ -69,6 +75,12 @@ export type ButtonSubConfig<T extends string> = T extends 'text'
* 按钮的文本。
*/
text?: string;
+ /**
+ * Extra attributes add to button HTML tag
+ *
+ * 添加到按钮 HTML 标签上的额外属性
+ */
+ extraAttr?: Record<string, string>;
} & (
| {
/**