fix(website): use custom highlighter

This commit is contained in:
LukaDev 2024-10-12 23:35:34 +02:00
parent fc0e9f96cd
commit 6c20193bd6

View file

@ -1,5 +1,5 @@
import { fetchRegistry, RegistryHttpError } from "$lib/registry-api"
import rehypeShiki from "@shikijs/rehype"
import rehypeShikiFromHighlighter from "@shikijs/rehype/core"
import rehypeRaw from "rehype-raw"
import rehypeSanitize from "rehype-sanitize"
import rehypeStringify from "rehype-stringify"
@ -7,10 +7,15 @@ import remarkGemoji from "remark-gemoji"
import remarkGfm from "remark-gfm"
import remarkParse from "remark-parse"
import remarkRehype from "remark-rehype"
import { createCssVariablesTheme } from "shiki"
import { createCssVariablesTheme, createHighlighter } from "shiki"
import { unified } from "unified"
import type { PageLoad } from "./$types"
const highlighter = await createHighlighter({
themes: [],
langs: [],
})
const fetchReadme = async (
fetcher: typeof fetch,
name: string,
@ -50,14 +55,14 @@ export const load: PageLoad = async ({ parent, fetch }) => {
.use(remarkRehype, { allowDangerousHtml: true })
.use(rehypeRaw)
.use(rehypeSanitize)
.use(rehypeShiki, {
.use(rehypeShikiFromHighlighter, highlighter, {
lazy: true,
theme: createCssVariablesTheme({
name: "css-variables",
variablePrefix: "--shiki-",
variableDefaults: {},
fontStyle: true,
}),
lazy: true,
fallbackLanguage: "text",
})
.use(rehypeStringify)