clarity-theme 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -271
- package/README.zh-CN.md +56 -290
- package/nuxt.config.ts +17 -1
- package/package.json +10 -2
- package/src/app.config.ts +8 -104
- package/src/assets/icons/zhilu.svg +8 -0
- package/src/blog.config.ts +71 -0
- package/src/components/blog/BlogFooter.vue +3 -3
- package/src/components/blog/BlogHeader.global.vue +9 -9
- package/src/components/blog/BlogSidebar.vue +3 -3
- package/src/components/blog/ThemeToggle.vue +2 -2
- package/src/components/content/Alert.vue +2 -2
- package/src/components/content/FeedCard.vue +2 -2
- package/src/components/content/Mermaid.vue +1 -1
- package/src/components/content/ProseCode.vue +4 -32
- package/src/components/content/ProsePre.vue +2 -2
- package/src/components/content/ProseTable.vue +1 -1
- package/src/components/popover/Search.vue +3 -3
- package/src/components/post/Comment.vue +3 -15
- package/src/components/post/Excerpt.vue +3 -3
- package/src/components/post/OrderToggle.vue +3 -3
- package/src/components/post/PostFooter.vue +3 -4
- package/src/components/post/PostHeader.vue +4 -4
- package/src/components/post/PostSurround.vue +2 -2
- package/src/components/post/Slide.vue +2 -2
- package/src/components/util/Img.vue +1 -1
- package/src/components/widget/BlogLog.vue +9 -19
- package/src/components/widget/BlogStats.vue +4 -4
- package/src/components/widget/BlogTech.vue +18 -17
- package/src/components/widget/CommGroup.vue +43 -0
- package/src/composables/useArticle.ts +9 -9
- package/src/composables/usePagination.ts +2 -2
- package/src/composables/useWidgets.ts +2 -0
- package/src/config/app.ts +50 -4
- package/src/config/content.ts +6 -0
- package/src/config/define.mjs +1 -1
- package/src/config/define.ts +1 -1
- package/src/config/feed.ts +2 -42
- package/src/config/pnpm-workspace.ts +19 -0
- package/src/config/public.ts +1 -1
- package/src/config/ui.ts +111 -0
- package/src/generated/blog.config.mjs +3 -0
- package/src/generated/package-json.mjs +4 -0
- package/src/generated/pnpm-workspace.mjs +1 -0
- package/src/modules/anti-mirror/index.ts +33 -0
- package/src/modules/{clarity-config/anti-mirror-client.ts → anti-mirror/runtime/client.ts} +3 -3
- package/src/modules/clarity-config/index.ts +335 -77
- package/src/modules/clarity-source-layout/index.ts +13 -0
- package/src/pages/archive.vue +4 -4
- package/src/pages/index.vue +4 -3
- package/src/pages/link.vue +5 -5
- package/src/pages/preview.vue +2 -2
- package/src/server/api/stats.get.ts +9 -19
- package/src/server/routes/atom.xml.get.ts +48 -50
- package/src/server/routes/subscriptions.opml.get.ts +14 -31
- package/src/shared/utils/time.ts +13 -18
- package/src/types/article.ts +2 -2
- package/src/types/feed.ts +35 -1
- package/src/types/upstream-compat.d.ts +17 -0
- package/src/types/yaml-modules.d.ts +26 -0
- package/src/shared/types/content.ts +0 -30
- package/src/types/modal.ts +0 -16
- /package/src/assets/icons/{solar-rewind-back-bold-duotone.svg → SolarRewindBackBoldDuotone.svg} +0 -0
- /package/src/assets/icons/{solar-rewind-forward-bold-duotone.svg → SolarRewindForwardBoldDuotone.svg} +0 -0
package/README.zh-CN.md
CHANGED
|
@@ -1,51 +1,55 @@
|
|
|
1
1
|
# Clarity Theme
|
|
2
2
|
|
|
3
|
+
[](https://github.com/iicemeta/clarity-theme/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/clarity-theme)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
3
7
|
[English](./README.md) | **简体中文**
|
|
4
8
|
|
|
5
9
|
Clarity Theme 是一个从 [L33Z22L11/blog-v3](https://github.com/L33Z22L11/blog-v3) 抽取出来的可复用 **Nuxt 4 Layer 博客主题**。它提供通用的博客 UI、页面结构、Markdown/MDC 渲染、SEO 集成以及 feed/服务端输出;你的项目只需要提供全部站点数据与内容。
|
|
6
10
|
|
|
7
|
-
##
|
|
11
|
+
## 为什么选择 Clarity?
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
- 带默认值校验的站点配置,并严格拒绝未知字段
|
|
11
|
-
- 用于文章元数据与站点地图数据的 Nuxt Content 集合工厂
|
|
12
|
-
- Markdown、MDC 组件、Shiki 代码高亮、KaTeX、Mermaid、ABC 乐谱与富图片
|
|
13
|
-
- 文章列表、归档、分页、目录(TOC)、搜索、主题切换、小部件、预览与 404 路由
|
|
14
|
-
- Atom、OPML、统计、robots、sitemap 与 LLMs 输出
|
|
15
|
-
- 由使用方配置驱动的 Twikoo、head 脚本与反镜像集成
|
|
16
|
-
- UI 默认值、app config 覆盖、自定义 Shiki 主题与同路径组件覆盖
|
|
17
|
-
- 自动化的 workspace、tarball 消费者、SSR、浏览器、水合、纯度、契约、peer 与上游同步检查
|
|
13
|
+
Clarity 取代传统的 sync fork 工作流。你不需要把上游数千行代码合并进博客仓库,而是以 Layer 方式消费主题,只维护自己的文件:
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
- **一条 `extends` 配置**即可安装完整的博客应用骨架
|
|
16
|
+
- **Theme 与 Consumer 分离**:文章、友链、重定向、部署配置、密钥与依赖补丁永远不会进入主题包
|
|
17
|
+
- **配置带校验**:`clarity.config.ts` 由 schema 校验,提供默认值并严格拒绝未知字段
|
|
18
|
+
- **Content 工厂**:Nuxt Content 集合与文章 schema 由你的配置派生
|
|
19
|
+
- **富渲染**:Markdown、MDC 组件、Shiki 代码高亮、KaTeX、Mermaid、ABC 乐谱与富图片
|
|
20
|
+
- **完整输出**:文章列表、归档、分页、目录(TOC)、搜索、主题切换、小部件、Atom、OPML、统计、robots、sitemap 与 LLMs
|
|
21
|
+
- **集成仍归你所有**:Twikoo、head 脚本与反镜像均由消费方配置驱动
|
|
22
|
+
- **覆盖而无需 fork**:UI app config 覆盖、同路径组件覆盖、自定义 Shiki 主题与消费方 CSS
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
| --- | --- |
|
|
23
|
-
| Node.js | `^22.19 \|\| ^24.11 \|\| >=26` |
|
|
24
|
-
| pnpm | 12.4.1,或适用于你项目的兼容包管理器 |
|
|
25
|
-
| Nuxt peer | `^4.5.2` |
|
|
26
|
-
| Vue peer | `^3.5.42` |
|
|
24
|
+
## 核心原则
|
|
27
25
|
|
|
28
|
-
Clarity
|
|
26
|
+
- **Clarity 是 blog-v3 的 Layer 化提取**,不是重新实现的独立主题。上游 UI、布局与交互默认是 source of truth,除 `tests/upstream-parity.manifest.json` 中显式记录的机械路径改写外保持 byte-identical。
|
|
27
|
+
- **上游硬编码行为优先保留**:泛化、配置化与清理属于后续路线,不属于本次 parity。
|
|
28
|
+
- **个人站点数据归消费方管理**,边界以上游 `init-project` 重置范围为准。
|
|
29
|
+
- **漂移即缺陷**:同步面内任何未登记差异都会让 `pnpm test:upstream-parity` 失败。
|
|
29
30
|
|
|
30
|
-
##
|
|
31
|
+
## 选择你的路径
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
| 起点 | 文档 |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| 新博客 | [创建项目](./docs/getting-started/new-project.zh-CN.md) |
|
|
36
|
+
| 现有 blog-v3 站点 | [从 blog-v3 迁移](./docs/getting-started/migration-from-blog-v3.zh-CN.md) · Agent Skill:`migrate-blog-v3-to-clarity` |
|
|
37
|
+
| 手动接入现有 Nuxt 应用 | [手动安装](./docs/getting-started/manual-installation.zh-CN.md) |
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
如需 Agent 协助迁移,直接让你的 Agent 使用 `migrate-blog-v3-to-clarity` Skill。完整 Skill 位于 [`skills/migrate-blog-v3-to-clarity`](./skills/migrate-blog-v3-to-clarity/SKILL.md)。
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
## 快速开始
|
|
39
42
|
|
|
40
43
|
```bash
|
|
41
|
-
pnpm
|
|
44
|
+
pnpm create clarity-theme my-blog
|
|
45
|
+
cd my-blog
|
|
46
|
+
pnpm dev
|
|
42
47
|
```
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## 快速开始
|
|
49
|
+
创建器会显示可编辑的站点默认值并自动检测系统时区;生成的项目自带
|
|
50
|
+
`pnpm new-blog` 写作命令。
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
创建包以独立的 `create-clarity-theme` npm 包分发,稳定版位于 `latest` dist-tag。完整参数见 [`create-clarity-theme/README.md`](./create-clarity-theme/README.md)。手动接入只需四个文件:
|
|
49
53
|
|
|
50
54
|
```ts
|
|
51
55
|
// nuxt.config.ts
|
|
@@ -54,8 +58,6 @@ export default defineNuxtConfig({
|
|
|
54
58
|
})
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
### 2. 定义站点配置
|
|
58
|
-
|
|
59
61
|
```ts
|
|
60
62
|
// clarity.config.ts
|
|
61
63
|
import { defineClarityConfig } from 'clarity-theme/config'
|
|
@@ -65,18 +67,11 @@ export default defineClarityConfig({
|
|
|
65
67
|
title: 'My Blog',
|
|
66
68
|
description: 'Notes about technology and life',
|
|
67
69
|
url: 'https://example.com/',
|
|
68
|
-
author: {
|
|
69
|
-
name: 'My Name',
|
|
70
|
-
avatar: '/avatar.webp',
|
|
71
|
-
},
|
|
70
|
+
author: { name: 'My Name', avatar: '/avatar.webp' },
|
|
72
71
|
},
|
|
73
72
|
})
|
|
74
73
|
```
|
|
75
74
|
|
|
76
|
-
`site.title`、`site.description`、`site.url` 与 `site.author.name` 为必填项。article、feed、stats、integration、feature 与 changelog 分组均为可选,并使用文档中记载的默认值。
|
|
77
|
-
|
|
78
|
-
### 3. 创建 Content schema
|
|
79
|
-
|
|
80
75
|
```ts
|
|
81
76
|
// content.config.ts
|
|
82
77
|
import { createClarityContentConfig } from 'clarity-theme/content'
|
|
@@ -85,276 +80,47 @@ import clarityConfig from './clarity.config'
|
|
|
85
80
|
export default createClarityContentConfig(clarityConfig)
|
|
86
81
|
```
|
|
87
82
|
|
|
88
|
-
文章放在 `content/posts/` 下,其他 Content 页面放在 `content/` 下。
|
|
89
|
-
|
|
90
|
-
### 4. 可选:提供友链数据
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
// feeds.ts
|
|
94
|
-
import type { FeedGroup } from 'clarity-theme/config'
|
|
95
|
-
|
|
96
|
-
const feeds: FeedGroup[] = []
|
|
97
|
-
|
|
98
|
-
export default feeds
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
如果没有这个文件,友链页面和 OPML 输出会使用空数据,并且构建时会记录一条警告。
|
|
102
|
-
|
|
103
|
-
### 5. 生成或开发
|
|
104
|
-
|
|
105
83
|
```bash
|
|
84
|
+
pnpm add clarity-theme
|
|
106
85
|
pnpm dev
|
|
107
|
-
pnpm generate
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
从现有 blog-v3 项目完整迁移的操作流程,见[迁移指南](./docs/MIGRATION.zh-CN.md)。主题数据与用户内容是被刻意分开的:这个包永远不会携带你的文章、友链、重定向、部署配置或包补丁。
|
|
111
|
-
|
|
112
|
-
## 从 blog-v3 迁移
|
|
113
|
-
|
|
114
|
-
完整的人工迁移指南见[迁移指南](./docs/MIGRATION.zh-CN.md)。如果你希望让当前 Agent 使用 `migrate-blog-v3-to-clarity` Skill 自动执行迁移,可以直接使用下面的提示词:
|
|
115
|
-
|
|
116
|
-
```markdown
|
|
117
|
-
请使用 `migrate-blog-v3-to-clarity` Skill,把当前这个 blog-v3 项目迁移到 Clarity Theme。
|
|
118
|
-
|
|
119
|
-
要求:
|
|
120
|
-
|
|
121
|
-
1. 先只读扫描项目,不立即修改。
|
|
122
|
-
2. 判断当前项目是否属于支持的 blog-v3 结构。
|
|
123
|
-
3. 检查 blog.config.ts、app/app.config.ts、content.config.ts、nuxt.config.ts、feeds.ts、redirects.json、patches、content、public、custom components、server、modules。
|
|
124
|
-
4. 生成迁移计划,并把所有风险项标出来。
|
|
125
|
-
5. 不修改文章正文和 frontmatter。
|
|
126
|
-
6. 不删除 content、public、redirects、patches 或未知自定义代码。
|
|
127
|
-
7. 能自动迁移的部分自动处理。
|
|
128
|
-
8. 需要人工判断的部分暂停修改并记录原因。
|
|
129
|
-
9. 迁移完成后执行 typecheck、generate 和兼容性验证。
|
|
130
|
-
10. 最后输出完整 migration report,包括修改文件、保留配置、人工处理项和测试结果。
|
|
131
|
-
|
|
132
|
-
整个过程只使用当前 Agent 串行执行,不启动并行 Agent。
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## 基础配置
|
|
136
|
-
|
|
137
|
-
| 文件 | 职责 |
|
|
138
|
-
| --- | --- |
|
|
139
|
-
| `clarity.config.ts` | 站点身份、文章语义、友链、统计、集成、功能开关、更新日志 |
|
|
140
|
-
| `app/app.config.ts` | 仅限可选的响应式 UI 覆盖 |
|
|
141
|
-
| `content.config.ts` | Nuxt Content 集合/schema |
|
|
142
|
-
| `feeds.ts` | 可选的友链数据 |
|
|
143
|
-
| 使用方 `runtimeConfig` | 环境相关配置,以及唯一合法的密钥存放位置 |
|
|
144
|
-
|
|
145
|
-
逐字段的默认值、可见性与示例见[配置说明](./docs/CONFIGURATION.zh-CN.md)。
|
|
146
|
-
|
|
147
|
-
可选分组示例:
|
|
148
|
-
|
|
149
|
-
```ts
|
|
150
|
-
export default defineClarityConfig({
|
|
151
|
-
site: {
|
|
152
|
-
title: 'My Blog',
|
|
153
|
-
description: 'A Nuxt blog',
|
|
154
|
-
url: 'https://example.com/',
|
|
155
|
-
author: { name: 'My Name' },
|
|
156
|
-
},
|
|
157
|
-
article: {
|
|
158
|
-
defaultCategory: 'Uncategorized',
|
|
159
|
-
categories: {
|
|
160
|
-
Tech: { icon: 'tabler:code', color: '#7777ff' },
|
|
161
|
-
},
|
|
162
|
-
types: { tech: {}, story: {} },
|
|
163
|
-
},
|
|
164
|
-
feed: { limit: 50, enableStyle: true },
|
|
165
|
-
features: {
|
|
166
|
-
atom: true,
|
|
167
|
-
opml: true,
|
|
168
|
-
stats: true,
|
|
169
|
-
antiMirror: false,
|
|
170
|
-
},
|
|
171
|
-
})
|
|
172
86
|
```
|
|
173
87
|
|
|
174
|
-
|
|
88
|
+
文章放在 `content/posts/` 下,其他 Content 页面放在 `content/` 下。可选的 `feeds.ts` 友链数据与部署说明见[手动安装](./docs/getting-started/manual-installation.zh-CN.md)。
|
|
175
89
|
|
|
176
|
-
##
|
|
90
|
+
## 环境要求
|
|
177
91
|
|
|
178
|
-
|
|
|
92
|
+
| 运行时 | 版本 |
|
|
179
93
|
| --- | --- |
|
|
180
|
-
|
|
|
181
|
-
|
|
|
182
|
-
|
|
|
183
|
-
|
|
|
184
|
-
| `clarity-theme/img` | 头像/favicon/图片 URL 辅助函数 |
|
|
185
|
-
|
|
186
|
-
Layer 还暴露了 `useClarityConfig()`、`useClaritySite()`、`useClarityArticle()` 与 `useClaritySiteFeedEntry()` 运行时自动导入,以及 `#clarity/feeds` 注入。它们是 Layer 契约,而不是独立的包子路径。
|
|
187
|
-
|
|
188
|
-
确切的导出/类型边界记录在 [API 文档](./docs/API.zh-CN.md) 中。
|
|
189
|
-
|
|
190
|
-
## 自定义
|
|
191
|
-
|
|
192
|
-
### UI 配置
|
|
193
|
-
|
|
194
|
-
```ts
|
|
195
|
-
// app/app.config.ts
|
|
196
|
-
export default defineAppConfig({
|
|
197
|
-
clarity: {
|
|
198
|
-
header: { emojiTail: ['📝'] },
|
|
199
|
-
pagination: { perPage: 10 },
|
|
200
|
-
nav: [
|
|
201
|
-
{
|
|
202
|
-
title: '',
|
|
203
|
-
items: [
|
|
204
|
-
{ icon: 'tabler:files', text: 'Articles', url: '/' },
|
|
205
|
-
{ icon: 'tabler:link', text: 'Friends', url: '/link' },
|
|
206
|
-
{ icon: 'tabler:archive', text: 'Archive', url: '/archive' },
|
|
207
|
-
],
|
|
208
|
-
},
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
})
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
对象会深度合并;数组会整体替换主题的值。
|
|
215
|
-
|
|
216
|
-
### 组件
|
|
217
|
-
|
|
218
|
-
在使用方项目中创建同路径的 Layer 相对组件即可替换,例如:
|
|
219
|
-
|
|
220
|
-
```text
|
|
221
|
-
app/components/content/Badge.vue
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
使用方组件优先于 Layer 组件。Nuxt 目前会针对这种有意的覆盖模式输出重名警告。
|
|
225
|
-
|
|
226
|
-
### Shiki 主题
|
|
227
|
-
|
|
228
|
-
在使用方项目中提供 `app/shiki.config.ts`。只有当该文件不存在时,才会使用主题的回退配置。
|
|
229
|
-
|
|
230
|
-
UI 分组、同路径组件覆盖、CSS 覆盖、服务端/路由自定义与 Shiki 归属详见[自定义说明](./docs/CUSTOMIZATION.zh-CN.md)。
|
|
231
|
-
|
|
232
|
-
## 兼容性与验证
|
|
233
|
-
|
|
234
|
-
验证套件覆盖:
|
|
235
|
-
|
|
236
|
-
- Playground 静态生成
|
|
237
|
-
- 独立的 `pnpm pack` 消费者安装
|
|
238
|
-
- Node 与 TypeScript 中的五个包导出
|
|
239
|
-
- 三种配置分支
|
|
240
|
-
- Markdown/MDC/代码/数学公式/Mermaid/乐谱/图片渲染
|
|
241
|
-
- 生产 SSR、真实浏览器渲染与开发水合
|
|
242
|
-
- 搜索、分页、归档、TOC、SEO、robots、sitemap、LLMs、Atom、OPML、统计、固定链接、404、Twikoo 分支、反镜像注入、UI 覆盖与组件覆盖
|
|
243
|
-
- 主题纯度、peer 依赖、同步工具与上游漂移
|
|
244
|
-
|
|
245
|
-
生成的发布矩阵见[兼容性说明](./docs/COMPATIBILITY.zh-CN.md)。当前的精确数量、已知限制、技术债与发布阻塞项见[项目状态](./docs/PROJECT-STATUS.zh-CN.md)与[路线图](./docs/ROADMAP.zh-CN.md)。发布前必须在确切的 commit 上重新按顺序运行整套验证;早先的结果不能替代。
|
|
94
|
+
| Node.js | `^22.19 \|\| ^24.11 \|\| >=26` |
|
|
95
|
+
| pnpm | 12.4.1,或适用于你项目的兼容包管理器 |
|
|
96
|
+
| Nuxt peer | `^4.5.2` |
|
|
97
|
+
| Vue peer | `^3.5.42` |
|
|
246
98
|
|
|
247
|
-
|
|
99
|
+
Clarity 属于应用运行时的一部分(Nuxt 构建与静态生成会直接加载 Layer),因此请将其安装为常规依赖,而不是开发依赖。
|
|
248
100
|
|
|
249
101
|
## 文档
|
|
250
102
|
|
|
251
|
-
|
|
252
|
-
| --- | --- |
|
|
253
|
-
| [项目状态](./docs/PROJECT-STATUS.zh-CN.md) | 当前快照、已验证能力、限制、技术债、缺口与里程碑 |
|
|
254
|
-
| [路线图](./docs/ROADMAP.zh-CN.md) | 按优先级排序的 P0/P1/P2 技术债清单、延后决策与里程碑顺序 |
|
|
255
|
-
| [迁移指南](./docs/MIGRATION.zh-CN.md) | 在采用 Clarity 的同时保留 blog-v3 的内容、配置、重定向、补丁、自定义代码与资源 |
|
|
256
|
-
| [架构](./docs/ARCHITECTURE.zh-CN.md) | 主题/使用方边界与构建/运行时数据流 |
|
|
257
|
-
| [API](./docs/API.zh-CN.md) | 公共包/Layer API 与内部实现的边界 |
|
|
258
|
-
| [配置说明](./docs/CONFIGURATION.zh-CN.md) | 字段级 Clarity 配置契约与示例 |
|
|
259
|
-
| [自定义说明](./docs/CUSTOMIZATION.zh-CN.md) | UI、组件、Shiki、CSS、服务端与路由覆盖 |
|
|
260
|
-
| [兼容性说明](./docs/COMPATIBILITY.zh-CN.md) | 生成的发布兼容性矩阵 |
|
|
261
|
-
| [上游同步](./docs/UPSTREAM.zh-CN.md) | 基线、manifest、命令、冲突与工作流 |
|
|
262
|
-
| [补丁说明](./docs/PATCHES.zh-CN.md) | 使用方补丁归属与当前结论 |
|
|
263
|
-
| [发布审计](./docs/RELEASE-AUDIT.zh-CN.md) | 收尾前工程审计与剩余发布门槛 |
|
|
264
|
-
| [发布清单](./docs/RELEASE-CHECKLIST.zh-CN.md) | 确切的最终检查、剩余阻塞项与验证证据 |
|
|
265
|
-
| [发布指南](./docs/PUBLISHING.zh-CN.md) | 版本管理、tag、GitHub Release、OIDC 发布、provenance 与回滚策略 |
|
|
266
|
-
| [更新日志](./CHANGELOG.md) | 面向使用者的发布历史 |
|
|
267
|
-
| [抽取历史](./docs/history/2026-09-layer-extraction.zh-CN.md) | 历史阶段与一次性差分验证 |
|
|
268
|
-
|
|
269
|
-
## 仓库结构
|
|
270
|
-
|
|
271
|
-
仓库根目录是工程管理层;Theme 的全部运行时源码统一放在 `src/`:
|
|
103
|
+
所有文档都有对应的简体中文版本(同名 `*.zh-CN.md` 文件)。入口见[文档索引](./docs/README.zh-CN.md):
|
|
272
104
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
│ ├─ config/ # config API 源码(npm ./config ./content ./schema)
|
|
280
|
-
│ ├─ img/ # img API 源码(npm ./img)
|
|
281
|
-
│ ├─ modules/ # source-layout 引导模块 + clarity-config 模块
|
|
282
|
-
│ ├─ public/ server/ shared/ remark-plugins/
|
|
283
|
-
├─ skills/ # Agent 工作流 Skill(不进入 npm 包)
|
|
284
|
-
├─ docs/ # 人工文档
|
|
285
|
-
├─ playground/ # workspace 链接的开发用消费项目
|
|
286
|
-
├─ scripts/ tests/ # 验证与工具脚本
|
|
287
|
-
└─ nuxt.config.ts、package.json、sync-manifest.json、…
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
`nuxt.config.ts` 保留在包根目录。它最先加载的
|
|
291
|
-
`src/modules/clarity-source-layout` 只为 Clarity 自身 layer 应用 `src/`
|
|
292
|
-
目录元数据;不静态声明 `srcDir`/`serverDir`/`dir.*`,是因为 c12 会把它们
|
|
293
|
-
合并进未显式覆盖这些键的 consumer root 配置。因此 npm 安装、Git commit
|
|
294
|
-
安装与本地目录安装解析到同一份布局,同时不会覆盖 consumer 自己的
|
|
295
|
-
应用目录。
|
|
296
|
-
|
|
297
|
-
npm 包、Agent Skill 与文档三者职责分离:
|
|
298
|
-
|
|
299
|
-
- **`clarity-theme`(npm 包)** — 运行时 Nuxt Layer,通过
|
|
300
|
-
`extends: ['clarity-theme']` 使用。`files` 只发布 `src/` 与根入口文件,
|
|
301
|
-
开发资产不会进入 tarball。
|
|
302
|
-
- **`skills/migrate-blog-v3-to-clarity`** — 迁移既有 blog-v3 项目的
|
|
303
|
-
Agent 工作流 Skill。它与仓库一起版本化,但**刻意不**打进 npm 包。
|
|
304
|
-
- **`docs/`** — 中英双语的人工文档。
|
|
305
|
-
|
|
306
|
-
### 安装迁移 Skill
|
|
307
|
-
|
|
308
|
-
```bash
|
|
309
|
-
npx skills add iicemeta/clarity-theme --list # 发现可用 Skill
|
|
310
|
-
npx skills add iicemeta/clarity-theme --skill migrate-blog-v3-to-clarity
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
开发环境可用 `npx skills add ./skills --list` 发现本地副本。让 Agent 迁移
|
|
314
|
-
blog-v3 站点时,请让它使用 `migrate-blog-v3-to-clarity` Skill;人工流程
|
|
315
|
-
见[迁移指南](./docs/MIGRATION.zh-CN.md)。
|
|
105
|
+
- **入门** — [创建新项目](./docs/getting-started/new-project.zh-CN.md)、[手动安装](./docs/getting-started/manual-installation.zh-CN.md)、[从 blog-v3 迁移](./docs/getting-started/migration-from-blog-v3.zh-CN.md)
|
|
106
|
+
- **指南** — [配置](./docs/guides/configuration.zh-CN.md)、[内容](./docs/guides/content.zh-CN.md)、[自定义](./docs/guides/customization.zh-CN.md)、[集成](./docs/guides/integrations.zh-CN.md)
|
|
107
|
+
- **参考** — [公共 API](./docs/reference/api.zh-CN.md)、[路由与输出](./docs/reference/routes-and-outputs.zh-CN.md)、[兼容性矩阵](./docs/reference/compatibility.zh-CN.md)
|
|
108
|
+
- **概念** — [架构](./docs/concepts/architecture.zh-CN.md)
|
|
109
|
+
- **维护者** — [开发](./docs/maintainers/development.zh-CN.md)、[测试](./docs/maintainers/testing.zh-CN.md)、[上游同步](./docs/maintainers/upstream-sync.zh-CN.md)、[补丁](./docs/maintainers/patches.zh-CN.md)、[发布](./docs/maintainers/publishing.zh-CN.md)、[发布清单](./docs/maintainers/release-checklist.zh-CN.md)、[项目状态](./docs/maintainers/project-status.zh-CN.md)、[路线图](./docs/maintainers/roadmap.zh-CN.md)、[文档规则](./docs/maintainers/documentation.zh-CN.md)
|
|
110
|
+
- **发布历史** — [CHANGELOG](./CHANGELOG.md);历史记录位于 [docs/history](./docs/history/)
|
|
316
111
|
|
|
317
112
|
## 开发
|
|
318
113
|
|
|
319
114
|
```bash
|
|
320
|
-
pnpm install
|
|
321
|
-
pnpm dev
|
|
322
|
-
pnpm generate
|
|
323
|
-
pnpm lint
|
|
115
|
+
pnpm install # Theme + playground workspace
|
|
116
|
+
pnpm dev # Playground dev server
|
|
117
|
+
pnpm generate # Playground static generation
|
|
118
|
+
pnpm lint # ESLint + Stylelint
|
|
324
119
|
pnpm typecheck
|
|
325
|
-
pnpm verify # 纯度/静态泄漏检查
|
|
326
|
-
pnpm peers check
|
|
327
|
-
pnpm test:sync
|
|
328
|
-
pnpm test:migration
|
|
329
|
-
pnpm test:contract
|
|
330
|
-
pnpm test:consumer
|
|
331
|
-
pnpm test:compatibility
|
|
332
|
-
pnpm pack --dry-run # 不落盘检查 npm tarball
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
CI 从包元数据推导 Node 与 pnpm 版本。它先在固定的 Node 矩阵上运行 lint/typecheck/verify/sync/migration/contract/peers,再在主 Node 版本上运行 playground 生成、真实消费者验收与渲染兼容性。另有一个每周工作流只检测并报告上游漂移。
|
|
336
|
-
|
|
337
|
-
确切的 CI 阶段与权限见[项目状态 → CI](./docs/PROJECT-STATUS.zh-CN.md#10-ci)。
|
|
338
|
-
|
|
339
|
-
## 上游同步
|
|
340
|
-
|
|
341
|
-
Clarity 从一个上游 Nuxt 博客抽取而来,并在 `sync-manifest.json` 中记录确切的已审查基线。同步工具区分可直接包含的路径、使用方持有的排除项、经过转换的主题契约与人工审查路径;未知的上游变更会阻止 apply。使用:
|
|
342
|
-
|
|
343
|
-
```bash
|
|
344
|
-
pnpm sync:check # 比较 manifest 基线与远端
|
|
345
|
-
pnpm sync:diff # 对上游变更分类
|
|
346
|
-
pnpm sync:apply # 事务式应用已审查的 include-only 变更
|
|
347
|
-
pnpm sync:verify # 重新运行主题纯度与基线检查
|
|
348
120
|
```
|
|
349
121
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
## 发布状态
|
|
353
|
-
|
|
354
|
-
Clarity Theme 是一个 **v0.1.2 门禁 npm 发布版本**。Layer/包边界、已校验配置、Content 工厂、渲染管线、服务端输出、playground、真实消费者验收、兼容性矩阵、三层 CI、上游同步基线、发布门禁与 OIDC 发布工作流均已实现。剩余的人工发布步骤见[发布检查清单](./docs/RELEASE-CHECKLIST.zh-CN.md)。
|
|
355
|
-
|
|
356
|
-
[路线图](./docs/ROADMAP.zh-CN.md)中的 v0.1.0 正确性门禁已解决:服务端/客户端配置已拆分、功能关闭路由在运行时返回 404、反镜像导航已在真实浏览器中验证、no-op 随机固定链接字段已移除,多模式统计已增加回归测试。其余推迟事项记录在路线图与发布说明中。
|
|
122
|
+
完整验证矩阵、上游同步与发布流程见[开发](./docs/maintainers/development.zh-CN.md)与[测试](./docs/maintainers/testing.zh-CN.md)。
|
|
357
123
|
|
|
358
124
|
## 许可证
|
|
359
125
|
|
|
360
|
-
|
|
126
|
+
主题代码为 MIT。上游博客的文章不包含在本包中。
|
package/nuxt.config.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { arch, env, version as nodeVersion, platform } from 'node:process'
|
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
4
4
|
import { name as ciName, CLOUDFLARE_PAGES, GITHUB_ACTIONS, NETLIFY } from 'ci-info'
|
|
5
5
|
import { Temporal } from 'temporal-polyfill'
|
|
6
|
+
import Yaml from 'unplugin-yaml/vite'
|
|
6
7
|
import { homepage, name as themeName, version as themeVersion } from './package.json'
|
|
7
8
|
|
|
8
9
|
/** Theme 根目录(Layer 本地路径基准,兼容 npm 包 / git 包 / 本地目录安装) */
|
|
@@ -88,6 +89,9 @@ export default defineNuxtConfig({
|
|
|
88
89
|
// Layer 配置中的相对 module 路径会以消费项目为基准解析,必须使用绝对路径;
|
|
89
90
|
// 且 clarity-config 必须先于 nuxt-llms 运行:后者在 setup 时读取注入的 llms 站点配置
|
|
90
91
|
toThemePath('src/modules/clarity-config'),
|
|
92
|
+
// 上游通过 Nuxt 的 modules 目录自动加载;Layer 场景下显式注册,且必须在
|
|
93
|
+
// clarity-config 之后(其导入 clarity-config 生成的 blog.config 数据模块)。
|
|
94
|
+
toThemePath('src/modules/anti-mirror'),
|
|
91
95
|
'nuxt-llms',
|
|
92
96
|
],
|
|
93
97
|
|
|
@@ -112,6 +116,13 @@ export default defineNuxtConfig({
|
|
|
112
116
|
},
|
|
113
117
|
|
|
114
118
|
typescript: {
|
|
119
|
+
// Theme 的 server 目录位于 src/ 内(跟随上游布局),会命中 App tsconfig
|
|
120
|
+
// 对 srcDir 的整体 include,导致 server 路由在 App 上下文被检查
|
|
121
|
+
// (queryCollection 等 Nitro 自动导入类型错误)。此处从 App tsconfig 排除;
|
|
122
|
+
// server 代码仍由 tsconfig.server.json 正常覆盖。
|
|
123
|
+
tsConfig: {
|
|
124
|
+
exclude: [toThemePath('src/server')],
|
|
125
|
+
},
|
|
115
126
|
nodeTsConfig: {
|
|
116
127
|
// @keep-sorted
|
|
117
128
|
include: [
|
|
@@ -122,6 +133,10 @@ export default defineNuxtConfig({
|
|
|
122
133
|
},
|
|
123
134
|
|
|
124
135
|
vite: {
|
|
136
|
+
// 上游 BlogTech 通过 `~~/pnpm-workspace.yaml` 读取技术栈版本,
|
|
137
|
+
// 需要 YAML 导入支持(上游注册 unplugin-yaml/nuxt;这里直接注册 vite 插件,
|
|
138
|
+
// 避免其向消费项目 compilerOptions.types 注入 pnpm 严格布局下无法解析的条目)
|
|
139
|
+
plugins: [Yaml()],
|
|
125
140
|
css: {
|
|
126
141
|
preprocessorOptions: {
|
|
127
142
|
scss: {
|
|
@@ -192,7 +207,8 @@ ${homepage}
|
|
|
192
207
|
|
|
193
208
|
icon: {
|
|
194
209
|
customCollections: [
|
|
195
|
-
|
|
210
|
+
// 上游使用 `zi` 前缀(zhilu icons)与原始 PascalCase 文件名,保持一致
|
|
211
|
+
{ prefix: 'zi', dir: toThemePath('src/assets/icons') },
|
|
196
212
|
],
|
|
197
213
|
clientBundle: {
|
|
198
214
|
scan: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clarity-theme",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"description": "Clarity Theme — 从 blog-v3 提取的可复用 Nuxt 4 Layer 博客主题",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"publishConfig": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@bikariya/modals": "^0.0.8",
|
|
55
55
|
"@bikariya/shiki": "^0.0.8",
|
|
56
56
|
"@iconify-json/catppuccin": "^1.2.17",
|
|
57
|
+
"@iconify-json/devicon": "^1.2.10",
|
|
57
58
|
"@iconify-json/line-md": "^1.2.16",
|
|
58
59
|
"@iconify-json/ri": "^1.2.10",
|
|
59
60
|
"@iconify-json/simple-icons": "^1.2.94",
|
|
@@ -95,8 +96,10 @@
|
|
|
95
96
|
"temporal-polyfill": "^1.0.4",
|
|
96
97
|
"ufo": "^1.6.0",
|
|
97
98
|
"unist-util-visit": "^5.1.0",
|
|
99
|
+
"unplugin-yaml": "^4.2.1",
|
|
98
100
|
"vfile": "^6.0.3",
|
|
99
101
|
"vue-tippy": "^6.7.1",
|
|
102
|
+
"yaml": "^2.9.1",
|
|
100
103
|
"zod": "^4.5.4"
|
|
101
104
|
},
|
|
102
105
|
"devDependencies": {
|
|
@@ -129,6 +132,7 @@
|
|
|
129
132
|
"lint": "eslint && stylelint \"src/**/*.{vue,scss}\" \"playground/app/**/*.vue\"",
|
|
130
133
|
"lint:fix": "eslint --fix && stylelint \"src/**/*.{vue,scss}\" \"playground/app/**/*.vue\" --fix",
|
|
131
134
|
"typecheck": "pnpm --dir playground typecheck",
|
|
135
|
+
"docs:check": "node scripts/check-docs.mjs",
|
|
132
136
|
"verify": "node scripts/verify-theme.mjs",
|
|
133
137
|
"test:sync": "node --test tests/sync-upstream.test.mjs",
|
|
134
138
|
"test:migration": "node --test tests/migration-skill.test.mjs",
|
|
@@ -136,11 +140,15 @@
|
|
|
136
140
|
"test:release": "pnpm verify && pnpm test:consumer && pnpm test:compatibility",
|
|
137
141
|
"test:consumer": "node scripts/test-consumer.mjs",
|
|
138
142
|
"test:compatibility": "node scripts/test-compatibility.mjs",
|
|
143
|
+
"test:create": "pnpm --dir create-clarity-theme test",
|
|
144
|
+
"test:create:e2e": "pnpm --dir create-clarity-theme test:e2e",
|
|
145
|
+
"test:create:tarball": "pnpm --dir create-clarity-theme test:tarball",
|
|
139
146
|
"test:registry-consumer": "node scripts/test-registry-consumer.mjs",
|
|
140
147
|
"release:check": "node scripts/release-check.mjs",
|
|
141
148
|
"sync:check": "node scripts/sync-upstream.mjs check",
|
|
142
149
|
"sync:diff": "node scripts/sync-upstream.mjs diff",
|
|
143
150
|
"sync:apply": "node scripts/sync-upstream.mjs apply",
|
|
144
|
-
"sync:verify": "node scripts/sync-upstream.mjs verify"
|
|
151
|
+
"sync:verify": "node scripts/sync-upstream.mjs verify",
|
|
152
|
+
"test:upstream-parity": "node scripts/test-upstream-parity.mjs"
|
|
145
153
|
}
|
|
146
154
|
}
|
package/src/app.config.ts
CHANGED
|
@@ -1,110 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Layer 级 app.config。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* UI 默认值由 src/modules/clarity-config 从 src/config/ui.ts 注入(inline 层),
|
|
5
|
+
* 此处仅提供需要字面量类型的键:pagination.sortOrder 若由模块注入,
|
|
6
|
+
* JSON 字面量会被宽化为 string,导致上游 useArticle 的
|
|
7
|
+
* ref<ArticleOrderType>(initialOrder) 类型不匹配。以 Layer cfg 提供
|
|
8
|
+
* 'date' 字面量(运行时与默认值一致,可被消费项目顶层键覆盖)。
|
|
8
9
|
*/
|
|
9
10
|
export default defineAppConfig({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
component: {
|
|
13
|
-
alert: {
|
|
14
|
-
/** 默认使用卡片风格还是扁平风格 */
|
|
15
|
-
defaultStyle: 'card' as 'card' | 'flat',
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
codeblock: {
|
|
19
|
-
/** 代码块触发折叠的行数 */
|
|
20
|
-
triggerRows: 32,
|
|
21
|
-
/** 代码块折叠后的行数 */
|
|
22
|
-
collapsedRows: 16,
|
|
23
|
-
/** 启用代码块缩进导航会关闭空格渲染 */
|
|
24
|
-
enableIndentGuide: true,
|
|
25
|
-
/** 代码块缩进导航竖线匹配空格数 */
|
|
26
|
-
indent: 4,
|
|
27
|
-
/** tab 渲染宽度 */
|
|
28
|
-
tabSize: 3,
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
/** 文章开头摘要 */
|
|
32
|
-
excerpt: {
|
|
33
|
-
animation: true,
|
|
34
|
-
caret: '_',
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
/** 精选文章 Slide */
|
|
38
|
-
slide: {
|
|
39
|
-
/** 适合封面图无字时启用 */
|
|
40
|
-
showTitle: true,
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
stats: {
|
|
44
|
-
/** 归档页面每年标题对应的年龄,无需展示时可留空 */
|
|
45
|
-
birthYear: undefined as number | undefined,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
// @keep-sorted
|
|
50
|
-
footer: {
|
|
51
|
-
/** 侧边栏底部图标导航 */
|
|
52
|
-
iconNav: [] as { icon: string, text: string, url: string }[],
|
|
53
|
-
/** 页脚站点地图 */
|
|
54
|
-
nav: [] as {
|
|
55
|
-
title: string
|
|
56
|
-
items: { icon: string, text: string, url: string }[]
|
|
57
|
-
}[],
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
/** 左侧栏顶部 Logo */
|
|
61
|
-
header: {
|
|
62
|
-
/** 展示标题文本,否则展示纯 Logo */
|
|
63
|
-
showTitle: true,
|
|
64
|
-
emojiTail: [] as string[],
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
/** 友链页面 */
|
|
68
|
-
link: {
|
|
69
|
-
/** 无订阅源展示静音图标 */
|
|
70
|
-
remindNoFeed: true,
|
|
71
|
-
/** 友链分组内随机排序 */
|
|
72
|
-
randomInGroup: true,
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
/** 左侧栏导航 */
|
|
76
|
-
nav: [
|
|
77
|
-
{
|
|
78
|
-
title: '',
|
|
79
|
-
items: [
|
|
80
|
-
{ icon: 'tabler:files', text: '文章', url: '/' },
|
|
81
|
-
{ icon: 'tabler:link', text: '友链', url: '/link' },
|
|
82
|
-
{ icon: 'tabler:archive', text: '归档', url: '/archive' },
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
|
|
87
|
-
pagination: {
|
|
88
|
-
perPage: 10,
|
|
89
|
-
/** 默认排序方式,需要是 article.order 中的键名 */
|
|
90
|
-
sortOrder: 'date',
|
|
91
|
-
/** 允许(普通/预览/归档)文章列表正序,开启后排序方式左侧图标可切换顺序 */
|
|
92
|
-
allowAscending: false,
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
themes: {
|
|
96
|
-
light: {
|
|
97
|
-
icon: 'tabler:sun',
|
|
98
|
-
tip: '浅色模式',
|
|
99
|
-
},
|
|
100
|
-
system: {
|
|
101
|
-
icon: 'tabler:device-desktop',
|
|
102
|
-
tip: '跟随系统',
|
|
103
|
-
},
|
|
104
|
-
dark: {
|
|
105
|
-
icon: 'tabler:moon',
|
|
106
|
-
tip: '深色模式',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
11
|
+
pagination: {
|
|
12
|
+
sortOrder: 'date' as const,
|
|
109
13
|
},
|
|
110
14
|
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 64" stroke="currentColor" height="1em" fill="none"
|
|
3
|
+
stroke-linecap="round" stroke-linejoin="round" stroke-width="8"
|
|
4
|
+
>
|
|
5
|
+
<!-- © Zhilu https://zhilu.site -->
|
|
6
|
+
<polyline points="4,4 36,4 5,45 37,45" />
|
|
7
|
+
<polyline points="43,19 12,60 44,60" />
|
|
8
|
+
</svg>
|