mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
Core: transformerIcon supports SVG string to extend codeblock icons
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-core': patch
|
||||
---
|
||||
|
||||
`transformerIcon` supports SVG string to extend codeblock icons
|
||||
@@ -1,10 +1,12 @@
|
||||
import { type ShikiTransformer } from 'shiki';
|
||||
|
||||
export interface CodeBlockIcon {
|
||||
viewBox: string;
|
||||
fill: string;
|
||||
d: string;
|
||||
}
|
||||
export type CodeBlockIcon =
|
||||
| {
|
||||
viewBox: string;
|
||||
fill: string;
|
||||
d: string;
|
||||
}
|
||||
| string;
|
||||
|
||||
const defaultShortcuts: Record<string, string> = {
|
||||
js: 'javascript',
|
||||
@@ -156,7 +158,10 @@ export function transformerIcon(options: IconOptions = {}): ShikiTransformer {
|
||||
const icon = iconName in icons ? icons[iconName] : defaultIcon;
|
||||
|
||||
if (icon) {
|
||||
pre.properties.icon = `<svg viewBox="${icon.viewBox}"><path d="${icon.d}" fill="${icon.fill}" /></svg>`;
|
||||
pre.properties.icon =
|
||||
typeof icon === 'string'
|
||||
? icon
|
||||
: `<svg viewBox="${icon.viewBox}"><path d="${icon.d}" fill="${icon.fill}" /></svg>`;
|
||||
}
|
||||
|
||||
return pre;
|
||||
|
||||
Reference in New Issue
Block a user