mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Fix code highlighting in Cloudflare (#27)
* Try calling WebAssembly.instantiate directly * Load from shikiji/onig.wasm instead
This commit is contained in:
+1
-2
@@ -32,8 +32,7 @@
|
||||
"server-only": "^0.0.1",
|
||||
"shikiji": "^0.8.0",
|
||||
"tailwind-merge": "^1.14.0",
|
||||
"tailwind-shades": "^1.1.2",
|
||||
"vscode-oniguruma": "^2.0.1"
|
||||
"tailwind-shades": "^1.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/next-on-pages": "^1.7.3",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DocumentBlockCode, DocumentBlockCodeLine, DocumentInlineAnnotation } from '@gitbook/api';
|
||||
import { getHighlighter, loadWasm, bundledLanguages, Highlighter, ThemedToken } from 'shikiji';
|
||||
// @ts-ignore - onigWasm is a Wasm module
|
||||
import onigWasm from 'vscode-oniguruma/release/onig.wasm?module';
|
||||
import onigWasm from 'shikiji/onig.wasm?module';
|
||||
|
||||
import { getNodeText } from '@/lib/document';
|
||||
|
||||
@@ -301,7 +301,7 @@ async function loadHighlighter() {
|
||||
// loads it on its own.
|
||||
//
|
||||
// Otherwise for Vercel/Cloudflare, we need to load it ourselves.
|
||||
await loadWasm(onigWasm);
|
||||
await loadWasm(obj => WebAssembly.instantiate(onigWasm, obj))
|
||||
}
|
||||
const instance = await getHighlighter();
|
||||
await instance.loadTheme('css-variables');
|
||||
|
||||
Reference in New Issue
Block a user