Skip to content

Commit

Permalink
wip(syntax-highlight): import client code async
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Sep 9, 2024
1 parent 8b77b12 commit 713d8d8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions client/src/document/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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]);
}
Expand Down

0 comments on commit 713d8d8

Please sign in to comment.