diff --git a/package-lock.json b/package-lock.json index e9de96e3..c2b4f33c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,8 @@ "shiki": "^0.14.5", "slugify": "^1.6.6", "unified": "^10.1.1", - "unist-util-visit": "^4.1.2" + "unist-util-visit": "^4.1.2", + "vscode-textmate": "^9.0.0" }, "devDependencies": { "@babel/preset-env": "^7.20.2", @@ -23719,6 +23720,11 @@ "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==" }, + "node_modules/vscode-textmate": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-9.0.0.tgz", + "integrity": "sha512-Cl65diFGxz7gpwbav10HqiY/eVYTO1sjQpmRmV991Bj7wAoOAjGQ97PpQcXorDE2Uc4hnGWLY17xme+5t6MlSg==" + }, "node_modules/w3c-xmlserializer": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz", diff --git a/package.json b/package.json index e6172e7e..1fccde21 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,8 @@ "shiki": "^0.14.5", "slugify": "^1.6.6", "unified": "^10.1.1", - "unist-util-visit": "^4.1.2" + "unist-util-visit": "^4.1.2", + "vscode-textmate": "^9.0.0" }, "devDependencies": { "@babel/preset-env": "^7.20.2", diff --git a/remix.config.js b/remix.config.js index 82e6555d..6acc8415 100644 --- a/remix.config.js +++ b/remix.config.js @@ -4,12 +4,6 @@ const config = { appDirectory: "src", ignoredRouteFiles: ["**/.*"], future: {}, - serverDependenciesToBundle: [ - "shiki", - "shiki/**/*", - "shiki/languages/**/*", - "shiki/themes/**/*", - ], serverModuleFormat: "esm", } diff --git a/src/utils/markdown.server.ts b/src/utils/markdown.server.ts index abc0fe86..377a291d 100644 --- a/src/utils/markdown.server.ts +++ b/src/utils/markdown.server.ts @@ -16,6 +16,7 @@ import remarkInlineLinks from "remark-inline-links" import remarkParse from "remark-parse" import remarkRehype from "remark-rehype" import remarkUnwrapImages from "remark-unwrap-images" +import {getHighlighter} from "shiki" import {unified} from "unified" import {codesandboxTransformer} from "~/transformers/codesandbox" @@ -51,6 +52,14 @@ const transformMarkdown = async (markdown: string): Promise => { const options: Options = { theme: json5.parse(theme), keepBackground: true, + getHighlighter: () => + getHighlighter({ + theme: json5.parse(theme), + paths: { + languages: path.join(process.cwd(), "src/shiki/languages"), + themes: path.join(process.cwd(), "src/shiki/themes"), + }, + }), } const processor = unified()