Skip to content

Commit 1e51345

Browse files
committed
doc: preliminray doc for blog system.
1 parent a5db603 commit 1e51345

2 files changed

Lines changed: 79 additions & 3 deletions

File tree

CONTRIBUTING.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@
257257
2. 文件名尽量和页面 slug 对应
258258
- 首页: [index.astro](src/contents/index.astro)
259259
- 教学实践: [teaching-practice.astro](src/contents/teaching-practice.astro)
260+
- 博客文章目录: [blog/](src/contents/blog/)
260261
3. 页面文案 i18n 采用 inline 形式,靠近实际渲染位置,例如:
261262
262263
```ts
@@ -269,6 +270,77 @@
269270
270271
4. 不要再新建集中式 page-content dictionary,除非真的有明确复用需求
271272
273+
## 博客系统 quick 'n dirty'
274+
275+
1. 文章目录
276+
- 所有博客文章都放在 [src/contents/blog/](src/contents/blog/)
277+
- 当前博客系统直接扫描这个目录下的 `.md` 文件,不走 Astro content collection
278+
- 因此不要再新建 `src/content/` 之类容易混淆的内容目录
279+
280+
2. 一篇文章最少需要这些 frontmatter
281+
282+
```md
283+
---
284+
title: "Demo/Test:首页时间线节点联调"
285+
summary: 用来测试首页 timeline 的显式 demo 文章,确认节点、跳转和时间排序都正常。
286+
date: 2026-05-19
287+
lang: zh
288+
category: Demo
289+
---
290+
```
291+
292+
字段说明:
293+
- `title`: 文章标题
294+
- `summary`: 摘要,会展示在博客列表和部分首页上下文里
295+
- `date`: 发布时间,决定排序
296+
- `lang`: 语言,只能是 `zh``en`
297+
- `category`: 可选,分类标签
298+
- `pinned`: 可选,`true` 时会优先排序
299+
- `draft`: 可选,`true` 时不会出现在页面里
300+
301+
3. 路由约定
302+
- 博客列表页:
303+
- `/zh/blog`
304+
- `/en/blog`
305+
- 博客详情页:
306+
- `/zh/blog/<slug>`
307+
- `/en/blog/<slug>`
308+
- 无语言前缀的 `/blog` 会重定向到默认语言 `/zh/blog`
309+
310+
4. 首页时间线
311+
- 首页 timeline/news 区域会自动读取博客目录中的最新文章
312+
- 宽屏下只显示当前布局能容纳的最新几篇
313+
- 窄屏下切换为竖向时间线
314+
- 新增文章后不需要手动改首页内容
315+
316+
5. 新增文章 quick 'n dirty
317+
1. 在 [src/contents/blog/](src/contents/blog/) 新建一个 markdown 文件
318+
2. 写好 frontmatter 和正文
319+
3. 如果做双语内容,分别新建 `*-zh.md` 和 `*-en.md`
320+
4. 运行:
321+
322+
```bash
323+
pnpm build
324+
```
325+
326+
327+
328+
```bash
329+
pnpm dev
330+
```
331+
332+
5. 确认:
333+
- `/zh/blog` 或 `/en/blog` 能看到文章
334+
- 首页 timeline 能看到对应节点
335+
- 点击节点能跳到详情页
336+
337+
6. 相关实现文件
338+
- 博客读取逻辑: [src/lib/blog.ts](src/lib/blog.ts)
339+
- 首页时间线组件: [src/components/HomeTimelineSection.astro](src/components/HomeTimelineSection.astro)
340+
- 博客详情布局: [src/layouts/BlogLayout.astro](src/layouts/BlogLayout.astro)
341+
- 博客列表页: [src/pages/[lang]/blog/index.astro](<src/pages/[lang]/blog/index.astro>)
342+
- 博客详情页: [src/pages/[lang]/blog/[slug].astro](<src/pages/[lang]/blog/[slug].astro>)
343+
272344
3. 路由 [src/pages](src/pages/)
273345
1. 无语言前缀路由入口 [\[...slug].astro](<src/pages/[...slug].astro>)
274346
@@ -281,6 +353,8 @@
281353
3. 目前内容页需要在这个文件里注册 slug,新增页面时记得一起改
282354
283355
4. 现有中文文档页 [src/pages/zh/about.md](src/pages/zh/about.md)
356+
5. 博客页已拆到独立路由目录 [src/pages/[lang]/blog/](<src/pages/[lang]/blog/>)
357+
- 博客文章不需要再在 [\[lang]/\[...slug].astro](<src/pages/[lang]/[...slug].astro>) 里手动注册
284358
285359
4. i18n [src/i18n](src/i18n/)
286360
1. [ui.ts](src/i18n/ui.ts)

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010

1111
这里是 YatCC AI 新版官网.
1212

13-
## Contribute
14-
15-
[贡献指北](./CONTRIBUTING.md).
13+
## Contribute
14+
15+
[贡献指北](./CONTRIBUTING.md).
16+
17+
博客系统的使用说明、文章目录约定和 timeline 行为也已经写进 [CONTRIBUTING.md](./CONTRIBUTING.md) 了。
1618

1719
## Deploy
1820

0 commit comments

Comments
 (0)