From 3b0d7d0b7d48f7a2838fb98b913c570a57578065 Mon Sep 17 00:00:00 2001 From: bluwy Date: Mon, 13 Nov 2023 22:22:52 +0800 Subject: [PATCH] Fix markdoc shiki --- packages/integrations/markdoc/src/extensions/shiki.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/integrations/markdoc/src/extensions/shiki.ts b/packages/integrations/markdoc/src/extensions/shiki.ts index 24829d16952f..c70ef7f08bf3 100644 --- a/packages/integrations/markdoc/src/extensions/shiki.ts +++ b/packages/integrations/markdoc/src/extensions/shiki.ts @@ -1,20 +1,17 @@ import Markdoc from '@markdoc/markdoc'; -import { createShikiHighlighter, type ShikiHighlighter } from '@astrojs/markdown-remark'; +import { createShikiHighlighter } from '@astrojs/markdown-remark'; import type { ShikiConfig } from 'astro'; import { unescapeHTML } from 'astro/runtime/server/index.js'; import type { AstroMarkdocConfig } from '../config.js'; export default async function shiki(config?: ShikiConfig): Promise { - let highlighterAsync: Promise | undefined; + const highlighter = await createShikiHighlighter(config); return { nodes: { fence: { attributes: Markdoc.nodes.fence.attributes!, - async transform({ attributes }) { - highlighterAsync ??= createShikiHighlighter(config); - const highlighter = await highlighterAsync; - + transform({ attributes }) { const lang = typeof attributes.language === 'string' ? attributes.language : 'plaintext'; const html = highlighter.highlight(attributes.content, lang);