新增:新增 Markdown 脚注、Markdown 公式支持

This commit is contained in:
2023-05-06 23:04:26 +08:00
parent cbd9de350b
commit 0eedb4a611
8 changed files with 621 additions and 1086 deletions

View File

@@ -1,4 +1,6 @@
import type { MarkdownOptions } from 'vitepress';
import mathjax3 from 'markdown-it-mathjax3';
import footnote from 'markdown-it-footnote';
export const markdown: MarkdownOptions = {
// Shiki主题, 所有主题参见: https://github.com/shikijs/shiki/blob/main/docs/themes.md
@@ -8,12 +10,15 @@ export const markdown: MarkdownOptions = {
},
// lineNumbers: true, // 启用行号
// 在所有文档的<h1>标签后添加<ArticleMetadata/>组件
config: (md) => {
md.use(mathjax3);
md.use(footnote);
// 在所有文档的<h1>标签后添加<ArticleMetadata/>组件
md.renderer.rules.heading_close = (tokens, idx, options, env, slf) => {
let htmlResult = slf.renderToken(tokens, idx, options);
if (tokens[idx].tag === 'h1') htmlResult += `\n<ClientOnly><ArticleMetadata v-if="($frontmatter?.aside ?? true) && ($frontmatter?.showArticleMetadata ?? true)" :article="$frontmatter" /></ClientOnly>`;
return htmlResult;
}
},
};
};