diff --git a/docs/.vitepress/api/gh-icon/[...data].get.ts b/docs/.vitepress/api/gh-icon/[...data].get.ts index e19a2f839..fc3505cce 100644 --- a/docs/.vitepress/api/gh-icon/[...data].get.ts +++ b/docs/.vitepress/api/gh-icon/[...data].get.ts @@ -15,8 +15,10 @@ export default eventHandler((event) => { const src = Buffer.from(data, 'base64').toString('utf8').replaceAll('\n', ''); - const width = parseInt((src.includes('svg') ? src.match(/width="(\d+)"/)?.[1] : null) ?? '24'); - const height = parseInt((src.includes('svg') ? src.match(/height="(\d+)"/)?.[1] : null) ?? '24'); + const width = parseInt((src.includes(' { .replaceAll('\n', '') .replace(/]*>|<\/svg>/g, ''); + const width = parseInt( + (newSrc.includes(' { const svg = Buffer.from( // We can't use jsx here, is not supported here by nitro. - renderToString(createElement(Diff, { oldSrc, newSrc, showGrid: true }, children)), + renderToString( + createElement(Diff, { oldSrc, newSrc, showGrid: true, height, width }, children), + ), ).toString('utf8'); defaultContentType(event, 'image/svg+xml'); diff --git a/docs/.vitepress/lib/SvgPreview/Backdrop.tsx b/docs/.vitepress/lib/SvgPreview/Backdrop.tsx index 2999f0acf..05d43f68d 100644 --- a/docs/.vitepress/lib/SvgPreview/Backdrop.tsx +++ b/docs/.vitepress/lib/SvgPreview/Backdrop.tsx @@ -53,8 +53,8 @@ const Backdrop = ({ @@ -67,8 +67,8 @@ const Backdrop = ({ ->(({ oldSrc, newSrc, children, ...props }, ref) => { +>(({ oldSrc, newSrc, children, height, width, ...props }, ref) => { return (