2023-12-23 09:15:00 +08:00

20 lines
585 B
TypeScript

import type { Plugin } from '@vuepress/core'
import { highlight } from './highlight.js'
import type { HighlighterOptions } from './types'
/**
* Options of @vuepress/plugin-shiki
*/
export type ShikijiPluginOptions = HighlighterOptions
export const shikijiPlugin = (
options: ShikijiPluginOptions = {}): Plugin => ({
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
},
})