From 88adb255dba62791019858af7544848365f47307 Mon Sep 17 00:00:00 2001 From: Northword <44738481+northword@users.noreply.github.com> Date: Sun, 4 Aug 2024 19:31:21 +0800 Subject: [PATCH] feat: support blog (#84) * stage: support blog * tweaks * refactor: mv blog posts to blog repo --- .gitmodules | 3 ++ .vscode/settings.json | 5 +++ src/.vitepress/config.ts | 3 +- src/.vitepress/config/navbar.config.ts | 1 + src/.vitepress/config/sidebar.config.ts | 1 + .../{theme/components => data}/blog.data.ts | 6 +-- src/.vitepress/theme/components/BlogIndex.vue | 37 ++++++++++++------- src/.vitepress/theme/components/Market.vue | 11 ++++-- src/blog/blog-repo | 1 + src/blog/index.md | 15 ++++++++ 10 files changed, 62 insertions(+), 21 deletions(-) rename src/.vitepress/{theme/components => data}/blog.data.ts (79%) create mode 160000 src/blog/blog-repo create mode 100644 src/blog/index.md diff --git a/.gitmodules b/.gitmodules index 9357c12..6a2350a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ [submodule "src/styles/detail"] path = src/styles/detail url = https://github.com/zotero-chinese/styles.git +[submodule "src/blog/blog-repo"] + path = src/blog/blog-repo + url = https://github.com/zotero-chinese/blog.git diff --git a/.vscode/settings.json b/.vscode/settings.json index 208fa90..5d4839b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -28,6 +28,11 @@ // }, "markdown.updateLinksOnFileMove.enabled": "always", "markdown.editor.pasteUrlAsFormattedLink.enabled": "smart", + "markdownlint.config": { + "MD025": { + "front_matter_title": "" + } + }, /** 文件管理器相关 */ // "explorer.sortOrder": "mixed", diff --git a/src/.vitepress/config.ts b/src/.vitepress/config.ts index 0dd18fb..b98dc37 100644 --- a/src/.vitepress/config.ts +++ b/src/.vitepress/config.ts @@ -13,12 +13,13 @@ export default defineConfig({ description: 'Zotero 非官方中文维护小组', lang: 'zh-CN', - srcExclude: ['wiki/index.md', '**/README.md'], + srcExclude: ['wiki/index.md', '**/README.md', '**/_template.md'], // outDir: 'dist', rewrites: { 'wiki/:id+': ':id+', 'styles/detail/src/:id+': 'styles/:id+', + 'blog/blog-repo/posts/:id+': 'blog/posts/:id+', }, cleanUrls: true, diff --git a/src/.vitepress/config/navbar.config.ts b/src/.vitepress/config/navbar.config.ts index 014d93e..5196e2d 100644 --- a/src/.vitepress/config/navbar.config.ts +++ b/src/.vitepress/config/navbar.config.ts @@ -25,6 +25,7 @@ export const nav: DefaultTheme.NavItem[] = [ { text: '社区', items: [ + { text: '博客', link: '/blog/' }, { text: '关于我们', link: '/about' }, { text: '贡献者名单', link: '/contributors' }, { text: '贡献指南', link: '/contributing/' }, diff --git a/src/.vitepress/config/sidebar.config.ts b/src/.vitepress/config/sidebar.config.ts index a31dbb8..7d95834 100644 --- a/src/.vitepress/config/sidebar.config.ts +++ b/src/.vitepress/config/sidebar.config.ts @@ -7,6 +7,7 @@ export const sidebar: DefaultTheme.Sidebar = { // "/styles/detail/": (() => { // return []; // })(), + '/blog/': [], '/': [ { text: '关于我们', link: '/about' }, { text: '贡献者名单', link: '/contributors' }, diff --git a/src/.vitepress/theme/components/blog.data.ts b/src/.vitepress/data/blog.data.ts similarity index 79% rename from src/.vitepress/theme/components/blog.data.ts rename to src/.vitepress/data/blog.data.ts index 8435e8e..20d34c3 100644 --- a/src/.vitepress/theme/components/blog.data.ts +++ b/src/.vitepress/data/blog.data.ts @@ -12,13 +12,13 @@ interface Post { declare const data: Post[] export { data } -export default createContentLoader('blog/*.md', { +export default createContentLoader('blog/blog-repo/posts/!(_template|index).md', { // excerpt: true, transform(raw): Post[] { return raw + .filter(({ frontmatter }) => !frontmatter.draft) .map(({ url, frontmatter }) => ({ - title: frontmatter.head.find(e => e[1].property === 'og:title')[1] - .content, + title: frontmatter.title, url, date: formatDate(frontmatter.date), })) diff --git a/src/.vitepress/theme/components/BlogIndex.vue b/src/.vitepress/theme/components/BlogIndex.vue index 2a6891a..103d419 100644 --- a/src/.vitepress/theme/components/BlogIndex.vue +++ b/src/.vitepress/theme/components/BlogIndex.vue @@ -1,5 +1,5 @@