From 713d8d83f33a28b866eac7ed8c6f26f6e7dbf4e8 Mon Sep 17 00:00:00 2001 From: Leo McArdle Date: Mon, 9 Sep 2024 09:21:32 +0000 Subject: [PATCH] wip(syntax-highlight): import client code async --- client/src/document/hooks.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/src/document/hooks.ts b/client/src/document/hooks.ts index caef0e44c10e..e104aab9fa96 100644 --- a/client/src/document/hooks.ts +++ b/client/src/document/hooks.ts @@ -13,7 +13,6 @@ import { } from "./code/playground"; import { addCopyToClipboardButton } from "./code/copy"; import { useUIStatus } from "../ui-context"; -import { highlightElement } from "./code/syntax-highlight"; export function useDocumentURL() { const locale = useLocale(); @@ -119,10 +118,12 @@ export function useDecorateExamples(doc: Doc | undefined) { } else { addCopyToClipboardButton(element, header); } - highlightElement( - element, - header?.querySelector(".language-name")?.textContent || "plain" - ); + import("./code/syntax-highlight").then(({ highlightElement }) => { + highlightElement( + element, + header?.querySelector(".language-name")?.textContent || "plain" + ); + }); }); }, [doc, location]); }