import pluginMdx from '@mdx-js/rollup'; import type { Plugin } from 'vite'; import remarkPluginGFM from 'remark-gfm'; import rehypePluginAutolinkHeadings from 'rehype-autolink-headings'; import rehypePluginSlug from 'rehype-slug'; import remarkPluginMDXFrontMatter from 'remark-mdx-frontmatter'; import remarkPluginFrontmatter from 'remark-frontmatter'; import { rehypePluginPreWrapper } from './rehypePlugins/preWrapper'; import { rehypePluginShiki } from './rehypePlugins/shiki'; import shiki from 'shiki'; import { remarkPluginToc } from './remarkPlugins/toc'; export async function pluginMdxRollup(): Promise { return pluginMdx({ remarkPlugins: [ remarkPluginGFM, remarkPluginFrontmatter, [remarkPluginMDXFrontMatter, { name: 'frontmatter' }], remarkPluginToc as unknown ], rehypePlugins: [ rehypePluginSlug, [ rehypePluginAutolinkHeadings, { properties: { class: 'header-anchor' }, content: { type: 'text', value: '#' } } ], rehypePluginPreWrapper as unknown, [ rehypePluginShiki, { highlighter: await shiki.getHighlighter({ themes: ['github-dark', 'nord', 'solarized-dark', 'material-theme-palenight'] }) } ] ] }) as unknown as Plugin; }