Files
blog/.vitepress/theme/index.ts
kerbores 558ba712eb 🎉 初始化
Signed-off-by: kerbores <kerbores@gmail.com>
2025-08-07 16:07:16 +08:00

36 lines
978 B
TypeScript

import DefaultTheme from "vitepress/theme";
import Antd from "ant-design-vue";
import "ant-design-vue/dist/reset.css"; // 或 antd.css:ml-citation{ref="1,9" data="citationList"}
export default {
extends: DefaultTheme,
enhanceApp({ app }) {
app.use(Antd);
// 添加全局标签处理逻辑
app.provide("tags", {
getAllTags() {
const posts = import.meta.glob("../posts/*.md", { eager: true });
const tags = {};
for (const path in posts) {
const { frontmatter } = posts[path] as { frontmatter: any };
if (frontmatter.tags) {
frontmatter.tags.forEach((tag) => {
if (!tags[tag]) tags[tag] = [];
tags[tag].push({
title: frontmatter.title,
date: frontmatter.date,
url: path.replace("../posts", "/posts").replace(".md", ""),
});
});
}
}
return tags;
},
});
},
};