feat(templates):新增 Markdown 内容页支持

新增 template: content:构建期使用 markdown-it 将本地Markdown 渲染为 HTML(禁用 raw HTML/图片),并按MeNav的URLscheme白名单策略对链接做安全降级
This commit is contained in:
rbetree
2026-01-20 17:43:06 +08:00
parent f773b9e290
commit 280d376bac
13 changed files with 642 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ templates/
│ └── default.hbs # 默认布局
├── pages/ # 页面模板 - 对应不同页面内容
│ ├── page.hbs # 通用页面模板(默认/回退模板;普通页面常用)
│ ├── content.hbs # 内容页Markdown 内容页:构建期渲染)
│ ├── projects.hbs # 项目页repo 风格卡片)
│ ├── articles.hbs # 文章页RSS 聚合/只读文章条目)
│ ├── bookmarks.hbs # 书签页
@@ -95,6 +96,7 @@ templates/
**主要页面**:
- `page.hbs` - 通用页面模板(默认/回退模板;普通页面常用)
- `content.hbs` - 内容页(从本地 Markdown 文件构建期渲染为 HTML
- `bookmarks.hbs` - 书签页
- `projects.hbs` - 项目页
- `articles.hbs` - 文章页
@@ -104,6 +106,21 @@ templates/
> 说明MeNav 不再依赖 `home.hbs` 作为首页模板。
> “首页/默认打开页”由 `site.yml -> navigation` 的**第一项**决定;首页可使用任意页面模板,具体取决于该页面配置(`pages/<homePageId>.yml` 的 `template` 字段与回退规则)。
#### 内容页template: content
内容页用于承载“关于 / 帮助 / 使用说明 / 更新日志 / 迁移指南”等纯文本内容。
- 内容来源:页面配置中的 `content.file` 指向本地 `.md` 文件(例如 `content/about.md`
- 渲染时机:**构建期** Markdown -> HTML不是运行时 fetch
- 安全约束:
- 禁止 raw HTML
- 禁止图片(`![]()` 不会被渲染)
- 链接会按 `site.yml -> security.allowedSchemes` 白名单策略处理,不安全链接会被降级为 `#`
对应模板文件:`templates/pages/content.hbs`
> 配置写法示例见:`config/README.md` 的“内容页template: content”。
**示例** (`page.hbs`):
```handlebars