mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 19:46:23 +00:00
25 lines
731 B
TypeScript
25 lines
731 B
TypeScript
import { QuartzTransformerPlugin } from "../types"
|
|
import rehypePrettyCode, { Options as CodeOptions } from "rehype-pretty-code"
|
|
|
|
export const SyntaxHighlighting: QuartzTransformerPlugin = () => ({
|
|
name: "SyntaxHighlighting",
|
|
markdownPlugins() {
|
|
return []
|
|
},
|
|
htmlPlugins() {
|
|
return [[rehypePrettyCode, {
|
|
theme: 'css-variables',
|
|
onVisitLine(node) {
|
|
if (node.children.length === 0) {
|
|
node.children = [{ type: 'text', value: ' ' }]
|
|
}
|
|
},
|
|
onVisitHighlightedLine(node) {
|
|
node.properties.className.push('highlighted')
|
|
},
|
|
onVisitHighlightedWord(node) {
|
|
node.properties.className = ['word']
|
|
},
|
|
} satisfies Partial<CodeOptions>]]
|
|
}
|
|
})
|