Skip to content

Commit f274eaf

Browse files
committed
Switch to shikiji
1 parent 82c4ae0 commit f274eaf

File tree

3 files changed

+101
-247
lines changed

3 files changed

+101
-247
lines changed

eleventy.config.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ const bundlerPlugin = require("@11ty/eleventy-plugin-bundle");
55
const eleventyImage = require("@11ty/eleventy-img");
66
const getImageSize = require("image-size").default;
77
const anchor = require("markdown-it-anchor").default;
8-
const { loadTheme } = require("shiki");
9-
const shikiMarkdown = require("markdown-it-shiki").default;
108
const faviconsPlugin = require("eleventy-plugin-gen-favicons");
119
const pluginRss = require("@11ty/eleventy-plugin-rss");
1210
const markdownIt = require("markdown-it");
11+
const { readFile } = require("fs/promises");
1312
const md = markdownIt({
1413
html: true,
1514
});
@@ -122,18 +121,24 @@ module.exports = (eleventyConfig) => {
122121

123122
eleventyConfig.setLibrary("md", md);
124123
eleventyConfig.amendLibrary("md", async (/** @type {import("markdown-it")} */ md) => {
125-
const theme = await loadTheme(path.join(__dirname, "dark_modern.json"));
124+
const { getHighlighter } = await import("shikiji");
125+
const { fromHighlighter } = await import("markdown-it-shikiji/core");
126+
const highlighter = await getHighlighter();
127+
const theme = JSON.parse(await readFile(path.join(__dirname, "dark_modern.json"), "utf8"));
128+
await highlighter.loadTheme(theme);
129+
await highlighter.loadLanguage("css", "js", "json", "shell", "tsx", "typescript");
126130
md.use(require("markdown-it-footnote"));
127131
md.use(require("@ryanxcharles/markdown-it-katex"));
128132
md.use(anchor, {
129133
permalink: anchor.permalink.headerLink({
130134
class: "no-underline",
131135
}),
132136
});
133-
md.use(shikiMarkdown, {
134-
theme,
135-
useBackground: true,
136-
});
137+
md.use(
138+
fromHighlighter(highlighter, {
139+
theme: "dark-modern",
140+
}),
141+
);
137142
});
138143

139144
eleventyConfig.addPlugin(faviconsPlugin, {

0 commit comments

Comments
 (0)