diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e4d6920..4d3db01 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,6 +56,41 @@ pnpm dev 文件名统一使用 kebab-case,如 `hello-world.md`。 +1. 博客置顶 + + 若有置顶某篇博客的需求,需要确保该博客文章在 frontmatter 中包含 `pinned: true` 字段。例如: + + ``` + --- + title: 2024 年飞桨开源社区年度报告 + date: 2025-02-07 + ... + pinned: true + --- + + 文章内容... + ``` + +2. 博客分类 + + 需要确保每篇博客文章在 frontmatter 中包含 `category` 字段,以便实现博客的分类展示。例如: + + ``` + --- + title: 文章标题 + date: 2025-04-01 + category: community-activity + --- + + 文章内容... + ``` + + | category 字段 | 含义 | + | ------------------ | ------------------------------ | + | community-activity | 飞桨开源社区动态、活动进展 | + | developer-story | 飞桨社区开发者访谈、开发者故事 | + | insights | 前沿洞察、技术分享 | + ### 图片文件 图片文件统一放置在 [`src/images`](./src/images) 目录下,每篇博客对应一个子目录,子目录名即为博客的文件名,比如 `hello-world.md` 对应的图片目录为 `src/images/hello-world`。 diff --git a/src/.vitepress/theme/BlogCategories.vue b/src/.vitepress/theme/BlogCategories.vue new file mode 100644 index 0000000..4d50e1a --- /dev/null +++ b/src/.vitepress/theme/BlogCategories.vue @@ -0,0 +1,35 @@ + + + + + + + {{ category.name }} + + + + diff --git a/src/.vitepress/theme/Home.vue b/src/.vitepress/theme/Home.vue index 92da5af..82a8dd5 100644 --- a/src/.vitepress/theme/Home.vue +++ b/src/.vitepress/theme/Home.vue @@ -1,23 +1,85 @@ @@ -31,6 +93,9 @@ const postsInPage = computed(() => { {{ frontmatter.subtext || site.description }} + + + @@ -56,9 +121,9 @@ const postsInPage = computed(() => { diff --git a/src/.vitepress/theme/Layout.vue b/src/.vitepress/theme/Layout.vue index 9fedbe5..fe73db0 100644 --- a/src/.vitepress/theme/Layout.vue +++ b/src/.vitepress/theme/Layout.vue @@ -1,19 +1,28 @@ - - + {{ site.title diff --git a/src/.vitepress/theme/Pagination.vue b/src/.vitepress/theme/Pagination.vue index b2740c9..7fd3f5e 100644 --- a/src/.vitepress/theme/Pagination.vue +++ b/src/.vitepress/theme/Pagination.vue @@ -1,10 +1,47 @@ @@ -17,7 +54,7 @@ const { numPages, pageIndex } = defineProps<{ }" v-for="i in numPages" :key="i" - :href="withBase(i === 1 ? '/index.html' : `/pages/${i}.html`)" + :href="getPageUrl(i)" >{{ i }} diff --git a/src/.vitepress/theme/loaders/posts.ts b/src/.vitepress/theme/loaders/posts.ts index 7d1828d..0ea636b 100644 --- a/src/.vitepress/theme/loaders/posts.ts +++ b/src/.vitepress/theme/loaders/posts.ts @@ -12,6 +12,7 @@ export interface Post { } excerpt: string | undefined pinned?: boolean + category?: string } export interface PostsData { @@ -80,6 +81,7 @@ export default function createPostsLoader(getPostsPerPage: () => number) { excerpt, date: formatDate(frontmatter.date), pinned: frontmatter.pinned === true, + category: frontmatter.category || 'all', })) .sort((a, b) => { if (a.pinned && !b.pinned) { diff --git a/src/posts/2023-os-report.md b/src/posts/2023-os-report.md index a03f5df..29ccf75 100644 --- a/src/posts/2023-os-report.md +++ b/src/posts/2023-os-report.md @@ -5,6 +5,7 @@ author: name: 梦师傅 github: Ligoml pinned: true +category: community-activity --- 什么是开源项目和开源社区?国内活跃度 Top 的开源社区,都有哪些有趣的人和事?开源社区之于开源项目有何重要意义? diff --git a/src/posts/2024-summary.md b/src/posts/2024-summary.md index 2b329a9..7ab0b46 100644 --- a/src/posts/2024-summary.md +++ b/src/posts/2024-summary.md @@ -5,6 +5,7 @@ author: name: 孙钟恺 github: sunzhongkai588 pinned: true +category: community-activity --- 2024 年已悄然落幕。这一年,飞桨开源社区在挑战与机遇中不断成长与突破。在这新年伊始,我们为大家呈上一份 2024 年度报告,以此致敬每一位开发者的努力与贡献。 diff --git a/src/posts/buaa-starter.md b/src/posts/buaa-starter.md index 0cd7209..1a4028c 100644 --- a/src/posts/buaa-starter.md +++ b/src/posts/buaa-starter.md @@ -4,6 +4,7 @@ date: 2024-11-27 author: name: 小莹莹 github: E-Pudding +category: community-activity ---
{{ frontmatter.subtext || site.description }}