2024-01-27 01:34:51 +08:00

19 lines
559 B
TypeScript

import type { Plugin } from 'vuepress/core'
import { highlight } from './highlight.js'
import type { HighlighterOptions } from './types'
export type ShikijiPluginOptions = HighlighterOptions
export function shikijiPlugin(options: ShikijiPluginOptions = {}): Plugin {
return {
name: '@vuepress-plume/plugin-shikiji',
extendsMarkdown: async (md) => {
const theme = options.theme ?? { light: 'github-light', dark: 'github-dark' }
const highlighter = await highlight(theme, options)
md.options.highlight = highlighter
},
}
}