hexo-theme-stellar 1.33.0 → 1.34.0
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/CLAUDE.md +217 -0
- package/README.md +2 -0
- package/_config.yml +35 -26
- package/docs/audits/2026-08-08-stellar-analysis.md +267 -0
- package/docs/release-process.md +59 -0
- package/layout/_partial/comments/artalk/script.ejs +56 -41
- package/layout/_partial/comments/beaudar/script.ejs +35 -20
- package/layout/_partial/comments/giscus/script.ejs +34 -19
- package/layout/_partial/comments/twikoo/script.ejs +29 -14
- package/layout/_partial/comments/utterances/script.ejs +35 -20
- package/layout/_partial/comments/waline/script.ejs +40 -28
- package/layout/_partial/cover/wiki_cover.ejs +1 -1
- package/layout/_partial/head.ejs +53 -4
- package/layout/_partial/scripts/defines.ejs +21 -3
- package/layout/_partial/scripts/lazyload.ejs +2 -2
- package/layout/_partial/scripts/services.ejs +101 -41
- package/layout/_partial/scripts/utils.ejs +144 -5
- package/layout/_partial/sidebar/index_leftbar.ejs +3 -0
- package/layout/_partial/sidebar/search.ejs +3 -0
- package/layout/_partial/widgets/ghuser.ejs +18 -4
- package/layout/_partial/widgets/linklist.ejs +1 -1
- package/layout/_partial/widgets/timeline.ejs +36 -33
- package/layout/_plugins/copycode.ejs +9 -5
- package/layout/_plugins/mathjax.ejs +47 -18
- package/layout/_plugins/mermaid.ejs +28 -24
- package/layout/_plugins/pjax.ejs +8 -0
- package/layout/_plugins/scrollreveal.ejs +14 -13
- package/layout/_plugins/swiper.ejs +2 -2
- package/layout/index.ejs +4 -2
- package/layout/index_topic.ejs +4 -2
- package/layout/index_wiki.ejs +6 -4
- package/layout/layout.ejs +3 -2
- package/package.json +2 -1
- package/scripts/commands/new-note.js +49 -0
- package/scripts/filters/lib/img_onerror.js +0 -2
- package/scripts/helpers/json_ld.js +11 -8
- package/scripts/helpers/pretty_url.js +5 -0
- package/scripts/tags/lib/chat.js +16 -9
- package/scripts/tags/lib/frame.js +2 -1
- package/scripts/tags/lib/image.js +6 -5
- package/scripts/tags/lib/link.js +6 -4
- package/scripts/tags/lib/timeline.js +101 -79
- package/source/css/_common/canonical.styl +11 -6
- package/source/css/_common/highlight.styl +4 -1
- package/source/css/_common/html.styl +4 -0
- package/source/css/_common/loading.styl +5 -1
- package/source/css/_components/md.styl +3 -0
- package/source/css/_components/pages/article-story.styl +2 -0
- package/source/css/_components/partial/article-footer.styl +1 -0
- package/source/css/_components/partial/navbar.styl +4 -2
- package/source/css/_components/sidebar/menu.styl +1 -0
- package/source/css/_components/sidebar/search.styl +4 -0
- package/source/css/_components/sidebar/sidebar.styl +12 -5
- package/source/css/_components/tag-plugins/chat.styl +6 -8
- package/source/css/_components/tag-plugins/folding.styl +1 -0
- package/source/css/_components/tag-plugins/gallery.styl +2 -0
- package/source/css/_components/tag-plugins/grid.styl +1 -0
- package/source/css/_components/tag-plugins/image.styl +3 -0
- package/source/css/_components/tag-plugins/link.styl +1 -0
- package/source/css/_components/tag-plugins/navbar.styl +15 -13
- package/source/css/_components/tag-plugins/note.styl +1 -0
- package/source/css/_components/tag-plugins/okr.styl +1 -0
- package/source/css/_components/tag-plugins/sites.styl +2 -0
- package/source/css/_components/tag-plugins/timeline.styl +9 -0
- package/source/css/_components/tag-plugins/vote.styl +2 -0
- package/source/css/_components/widgets/components.styl +1 -0
- package/source/css/_components/widgets/ghuser.styl +19 -3
- package/source/css/_components/widgets/list.styl +1 -0
- package/source/css/_components/widgets/toc.styl +3 -0
- package/source/css/_components/widgets/widgets.styl +4 -0
- package/source/css/_custom.styl +6 -3
- package/source/css/_defines/func.styl +24 -8
- package/source/css/_defines/theme_base.styl +1 -1
- package/source/css/_plugins/comments/artalk.styl +6 -2
- package/source/css/_plugins/comments/twikoo.styl +2 -0
- package/source/css/_plugins/index.styl +2 -0
- package/source/css/_plugins/pjax.styl +61 -0
- package/source/js/main.js +80 -26
- package/source/js/plugins/copycode.js +34 -27
- package/source/js/plugins/pjax.js +646 -0
- package/source/js/search/local-search.js +5 -2
- package/source/js/services/memos.js +42 -4
- package/source/js/services/rss.js +200 -0
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Stellar Theme Development
|
|
2
|
+
|
|
3
|
+
这是 Hexo 主题 **Stellar** 的仓库。主题是一个独立的 npm 包,用于 [hexo-theme-stellar](https://github.com/xaoxuu/hexo-theme-stellar)。
|
|
4
|
+
|
|
5
|
+
## 技术栈
|
|
6
|
+
|
|
7
|
+
| 层级 | 技术 | 目录 |
|
|
8
|
+
|------|------|------|
|
|
9
|
+
| 模板引擎 | EJS | `layout/` |
|
|
10
|
+
| CSS 预处理 | Stylus | `source/css/` |
|
|
11
|
+
| 服务端 JS | CommonJS (ES5) | `scripts/` |
|
|
12
|
+
| 浏览器 JS | ES5 (Babel 转译) | `source/js/` |
|
|
13
|
+
| 国际化 | YAML | `languages/` |
|
|
14
|
+
| 文档 | Markdown | `docs/` |
|
|
15
|
+
|
|
16
|
+
## 目录结构
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
layout/ # EJS 模板
|
|
20
|
+
├── _partial/ # 可复用组件
|
|
21
|
+
│ ├── main/ # 文章列表、导航、页脚
|
|
22
|
+
│ ├── sidebar/ # 侧栏组件
|
|
23
|
+
│ ├── cover/ # 封面
|
|
24
|
+
│ ├── comments/ # 评论系统
|
|
25
|
+
│ ├── widgets/ # 小部件
|
|
26
|
+
│ └── scripts/ # 脚本注入
|
|
27
|
+
├── _plugins/ # 可选插件片段
|
|
28
|
+
├── layout.ejs # 根布局
|
|
29
|
+
├── index.ejs # 首页
|
|
30
|
+
├── page.ejs # 通用页面
|
|
31
|
+
└── archive.ejs # 归档页
|
|
32
|
+
scripts/ # Hexo 服务端脚本
|
|
33
|
+
├── tags/ # 自定义标签 `{% tag %}`
|
|
34
|
+
│ └── lib/ # 标签实现
|
|
35
|
+
├── helpers/ # EJS 辅助函数
|
|
36
|
+
├── filters/ # Hexo 过滤器
|
|
37
|
+
├── generators/ # 页面生成器
|
|
38
|
+
├── events/ # 事件处理
|
|
39
|
+
└── commands/ # CLI 命令
|
|
40
|
+
source/ # 浏览器端资源
|
|
41
|
+
├── css/ # Stylus 样式
|
|
42
|
+
│ ├── _defines/ # 变量和函数
|
|
43
|
+
│ ├── _common/ # 通用基础样式
|
|
44
|
+
│ ├── _components/ # 组件样式
|
|
45
|
+
│ └── _plugins/ # 插件样式
|
|
46
|
+
└── js/ # 浏览器 JavaScript
|
|
47
|
+
├── plugins/ # 交互插件
|
|
48
|
+
├── services/ # 数据服务
|
|
49
|
+
└── search/ # 搜索
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## EJS 模板规范
|
|
53
|
+
|
|
54
|
+
- `<% %>` 逻辑控制,`<%- %>` 输出非转义 HTML
|
|
55
|
+
- 变量声明用 `var`(IE8 兼容)
|
|
56
|
+
- 2 空格缩进,HTML 属性双引号
|
|
57
|
+
- 可复用片段提取到 `_partial/`
|
|
58
|
+
- 复杂逻辑提取到 `helpers/` 辅助函数
|
|
59
|
+
|
|
60
|
+
```ejs
|
|
61
|
+
<%
|
|
62
|
+
var items = site.posts.sort('date', -1).limit(10)
|
|
63
|
+
items.forEach(function(post) {
|
|
64
|
+
%>
|
|
65
|
+
<article>
|
|
66
|
+
<%- partial('_partial/main/post_list/post_card', {post: post}) %>
|
|
67
|
+
</article>
|
|
68
|
+
<%
|
|
69
|
+
})
|
|
70
|
+
%>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Node.js 脚本规范
|
|
74
|
+
|
|
75
|
+
- CommonJS: `require()` / `module.exports`
|
|
76
|
+
- 文件头: `/* global hexo */` + `'use strict';`
|
|
77
|
+
- 2 空格缩进,双引号,分号结尾
|
|
78
|
+
- 标签注册: `hexo.extend.tag.register(name, handler, options)`
|
|
79
|
+
- 辅助函数注册: `hexo.extend.helper.register(name, handler)`
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
/* global hexo */
|
|
83
|
+
'use strict';
|
|
84
|
+
|
|
85
|
+
module.exports = function(hexo) {
|
|
86
|
+
return function(args, content) {
|
|
87
|
+
var result = '';
|
|
88
|
+
// ...
|
|
89
|
+
return result;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Stylus 样式规范
|
|
95
|
+
|
|
96
|
+
- 文件引入顺序: `const` → `custom` → `theme_base` → `theme_colorful` → `func`
|
|
97
|
+
- 类名和文件名: `kebab-case`
|
|
98
|
+
- 变量在 `_defines/`,通用样式在 `_common/`,组件在 `_components/`
|
|
99
|
+
- 2 空格缩进,属性后空格
|
|
100
|
+
- CSS 兼容 IE8
|
|
101
|
+
|
|
102
|
+
## 浏览器 JS 规范
|
|
103
|
+
|
|
104
|
+
- ES5 语法(Gulp Babel 转译为 ES2015+)
|
|
105
|
+
- 避免直接操作 DOM,使用主题工具函数
|
|
106
|
+
- 注释: `//` 单行,`/* */` 多行
|
|
107
|
+
|
|
108
|
+
## 工作流程
|
|
109
|
+
|
|
110
|
+
每次修改必须遵循以下流程,产物保留在仓库中:
|
|
111
|
+
|
|
112
|
+
### 1. 方案
|
|
113
|
+
|
|
114
|
+
在 `docs/` 目录下创建或更新方案文档,描述:
|
|
115
|
+
- 要解决的问题或新增的能力
|
|
116
|
+
- 技术方案和实现思路
|
|
117
|
+
- 影响范围(涉及哪些文件/模块)
|
|
118
|
+
|
|
119
|
+
### 2. 执行计划
|
|
120
|
+
|
|
121
|
+
方案通过后,列出具体执行步骤,记录在对应文档中:
|
|
122
|
+
- 改动文件清单
|
|
123
|
+
- 分步实施顺序
|
|
124
|
+
- 依赖关系
|
|
125
|
+
|
|
126
|
+
### 3. 测试
|
|
127
|
+
|
|
128
|
+
变更完成后,在自己的 Hexo 项目中集成验证:
|
|
129
|
+
- **`npm run g && npx gulp minify` 全量验证**(`scripts/` 变更必须执行:`npm run g` 发现模板渲染错误,`npx gulp minify` 发现 HTML 结构错误如多余引号等)
|
|
130
|
+
- `npm run s` 启动本地服务
|
|
131
|
+
- 检查涉及的所有页面类型(首页、文章页、Wiki 页等)
|
|
132
|
+
- 验证浏览器兼容性
|
|
133
|
+
- 测试结果记录在 `docs/` 中
|
|
134
|
+
|
|
135
|
+
### 4. 文档归档
|
|
136
|
+
|
|
137
|
+
- 方案、执行计划、测试记录保存在 `docs/` 目录
|
|
138
|
+
- 文件命名: `docs/{YYYY-MM-DD}-{功能简称}.md`
|
|
139
|
+
- 涉及逻辑变更(API、配置项、行为变化)必须同步更新仓库 Wiki
|
|
140
|
+
|
|
141
|
+
### 新增功能 Checklist
|
|
142
|
+
|
|
143
|
+
新增功能必须覆盖以下维度:
|
|
144
|
+
|
|
145
|
+
1. `layout/` — EJS 模板
|
|
146
|
+
2. `scripts/` — Hexo 标签 / 辅助函数 / 过滤器
|
|
147
|
+
3. `source/css/` — Stylus 样式
|
|
148
|
+
4. `source/js/` — 浏览器脚本(如需)
|
|
149
|
+
5. `docs/` — 方案 + 执行计划 + 测试记录
|
|
150
|
+
6. `languages/` — 国际化文案(如需新增文本)
|
|
151
|
+
|
|
152
|
+
## 组件架构
|
|
153
|
+
|
|
154
|
+
### 自定义标签开发
|
|
155
|
+
|
|
156
|
+
1. 在 `scripts/tags/lib/` 下创建标签实现文件
|
|
157
|
+
2. 在 `scripts/tags/index.js` 中注册
|
|
158
|
+
3. 在 `source/css/_components/tag-plugins/` 添加对应样式
|
|
159
|
+
4. 推荐使用 `hexo` 参数传入,避免 `require('hexo')`
|
|
160
|
+
|
|
161
|
+
### 评论系统
|
|
162
|
+
|
|
163
|
+
- 接口目录: `layout/_partial/comments/`
|
|
164
|
+
- 每个评论系统提供 `layout.ejs` 和 `script.ejs`
|
|
165
|
+
- 遵循现有的配置驱动模式
|
|
166
|
+
|
|
167
|
+
## Git 规范
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
<type>(<scope>): <description>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
| Type | 说明 |
|
|
174
|
+
|------|------|
|
|
175
|
+
| `feat` | 新功能 |
|
|
176
|
+
| `fix` | Bug 修复 |
|
|
177
|
+
| `refactor` | 重构 |
|
|
178
|
+
| `perf` | 性能优化 |
|
|
179
|
+
| `style` | CSS/样式修改 |
|
|
180
|
+
| `docs` | 文档更新 |
|
|
181
|
+
|
|
182
|
+
## 发版规范
|
|
183
|
+
|
|
184
|
+
发版分两步:脚本完成版本号更新和推送 → CI 自动完成 npm 发布和 tag 创建。
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
npm-publish.sh → push main + npm → CI → npm publish + git tag
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 使用方式
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# 正常发版(CI 自动处理 npm publish 和 tag)
|
|
194
|
+
bash npm-publish.sh 1.33.2
|
|
195
|
+
|
|
196
|
+
# 预览模式(仅显示改动,不提交/推送,执行后自动回滚)
|
|
197
|
+
bash npm-publish.sh 1.33.2 --dry-run
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### AI 调用指南
|
|
201
|
+
|
|
202
|
+
1. **分析变更确定版本号**: 查看上一版本以来的 commit,按以下规则确定版本号:
|
|
203
|
+
- `x.y.z` → `x.y.(z+1)`: 仅含 fix / perf / style(修复和优化,安全升级)
|
|
204
|
+
- `x.y.z` → `x.(y+1).0`: 含 feat / refactor / breaking change(功能增减、一般重构)
|
|
205
|
+
- `x.y.z` → `(x+1).0.0`: 大型重构,用户可感知的设计调整
|
|
206
|
+
- `x.y.z` → `x.y.z-rc.N`: 测试版本
|
|
207
|
+
2. **向用户确认**: 列出版本号和变更摘要,等待用户确认后再继续
|
|
208
|
+
3. **dry-run 预览**: `bash npm-publish.sh <version> --dry-run` 检查变更是否正确
|
|
209
|
+
4. **正式执行**: `bash npm-publish.sh <version>`
|
|
210
|
+
5. **CI 自动**: 检测 `release:` commit → npm publish + tag
|
|
211
|
+
|
|
212
|
+
## 约束
|
|
213
|
+
|
|
214
|
+
- **修改 `scripts/` 目录下任何文件后,必须运行 `npm run g && npx gulp minify` 验证构建成功。** `npm run g` 做全量渲染发现模板错误,`npx gulp minify` 做 HTML 压缩发现结构错误(如多余引号)。`npm run s` 是按需渲染,不能替代全量验证。
|
|
215
|
+
- 不引入新构建系统,保持 Hexo 原生 + Gulp 后处理
|
|
216
|
+
- 不混用 EJS 和前端框架语法
|
|
217
|
+
- CSS 兼容 IE8,JS 兼容 ES2015+
|
package/README.md
CHANGED
package/_config.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
######## Stellar info ########
|
|
2
2
|
stellar:
|
|
3
|
-
version: '1.
|
|
3
|
+
version: '1.34.0'
|
|
4
4
|
homepage: 'https://xaoxuu.com/wiki/stellar/'
|
|
5
5
|
repo: 'https://github.com/xaoxuu/hexo-theme-stellar'
|
|
6
6
|
main_css: /css/main.css
|
|
@@ -9,13 +9,16 @@ stellar:
|
|
|
9
9
|
|
|
10
10
|
######## head tags ########
|
|
11
11
|
preconnect:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
- https://gcore.jsdelivr.net
|
|
13
|
+
- https://unpkg.com
|
|
14
|
+
- https://cdn.jsdelivr.net
|
|
15
|
+
- https://cdnjs.cloudflare.com
|
|
15
16
|
|
|
16
17
|
# 一旦设置源站地址,非源站地址将不会被SEO收录,并且访问时弹出提示
|
|
17
18
|
# 如果访问地址不在备用站主机列表,则警告信息为非法克隆
|
|
18
19
|
canonical:
|
|
20
|
+
closeEnable: true # 是否显示关闭提示按钮
|
|
21
|
+
closeText: 关闭提示 # 关闭提示按钮的文字描述
|
|
19
22
|
originalHost: # 主站点域名主机,例如 xaoxuu.com
|
|
20
23
|
officialHosts: # 官方主机列表,每行一个,例如 xaoxuu.vercel.app
|
|
21
24
|
- localhost
|
|
@@ -311,8 +314,8 @@ comments:
|
|
|
311
314
|
# Artalk
|
|
312
315
|
# https://artalk.js.org/
|
|
313
316
|
artalk:
|
|
314
|
-
css: https://unpkg.com/artalk@2.9/dist/
|
|
315
|
-
js: https://unpkg.com/artalk@2.9/dist/
|
|
317
|
+
css: https://unpkg.com/artalk@2.9/dist/artalk.css
|
|
318
|
+
js: https://unpkg.com/artalk@2.9/dist/artalk.js
|
|
316
319
|
server: # 后端服务地址
|
|
317
320
|
site: '' # 站点名称
|
|
318
321
|
darkMode: auto # 其它模式都有问题,慎用,否则后果自负
|
|
@@ -392,12 +395,12 @@ tag_plugins:
|
|
|
392
395
|
prefix: ph:seal-question-fill
|
|
393
396
|
# {% emoji %}
|
|
394
397
|
emoji:
|
|
395
|
-
default: https://gcore.jsdelivr.net/gh/cdn-x/
|
|
398
|
+
default: https://gcore.jsdelivr.net/gh/cdn-x/emoticons@3.1/qq/{name}.gif
|
|
396
399
|
twemoji: https://gcore.jsdelivr.net/gh/twitter/twemoji/assets/svg/{name}.svg
|
|
397
|
-
qq: https://gcore.jsdelivr.net/gh/cdn-x/
|
|
398
|
-
aru: https://gcore.jsdelivr.net/gh/cdn-x/
|
|
399
|
-
tieba: https://gcore.jsdelivr.net/gh/cdn-x/
|
|
400
|
-
blobcat: https://gcore.jsdelivr.net/gh/cdn-x/
|
|
400
|
+
qq: https://gcore.jsdelivr.net/gh/cdn-x/emoticons@3.1/qq/{name}.gif
|
|
401
|
+
aru: https://gcore.jsdelivr.net/gh/cdn-x/emoticons@3.1/aru/{name}.gif
|
|
402
|
+
tieba: https://gcore.jsdelivr.net/gh/cdn-x/emoticons@3.1/tieba/{name}.png
|
|
403
|
+
blobcat: https://gcore.jsdelivr.net/gh/cdn-x/emoticons@3.1/blobcat/{name}.gif
|
|
401
404
|
icon:
|
|
402
405
|
# 留空时,图标和文字颜色相同
|
|
403
406
|
default_color: accent # theme, accent, red, orange, yellow, green, cyan, blue, purple
|
|
@@ -451,7 +454,7 @@ tag_plugins:
|
|
|
451
454
|
|
|
452
455
|
# 基础依赖
|
|
453
456
|
dependencies:
|
|
454
|
-
jquery: https://gcore.jsdelivr.net/npm/jquery@3.7/dist/jquery.min.js
|
|
457
|
+
jquery: https://gcore.jsdelivr.net/npm/jquery@3.7/dist/jquery.slim.min.js
|
|
455
458
|
marked: https://gcore.jsdelivr.net/npm/marked@13.0/lib/marked.umd.min.js
|
|
456
459
|
lazyload:
|
|
457
460
|
js: https://gcore.jsdelivr.net/npm/vanilla-lazyload@19.1/dist/lazyload.min.js
|
|
@@ -516,7 +519,8 @@ data_services:
|
|
|
516
519
|
'_posts/': # https://github.com/xaoxuu/xaoxuu.com/blob/main/source/_posts/
|
|
517
520
|
'wiki/stellar/': https://github.com/xaoxuu/hexo-theme-stellar-docs/blob/main/
|
|
518
521
|
js: /js/services/contributors.js
|
|
519
|
-
|
|
522
|
+
rss:
|
|
523
|
+
js: /js/services/rss.js
|
|
520
524
|
|
|
521
525
|
# 扩展插件接入方法:(插件名下面用 #plugin# 代替)
|
|
522
526
|
# 1. 在这里增加 #plugin# 配置,至少应含有 enable 字段,默认为空(不启用)
|
|
@@ -533,11 +537,19 @@ plugins:
|
|
|
533
537
|
service: flying_pages # flying_pages
|
|
534
538
|
flying_pages: https://gcore.jsdelivr.net/npm/flying-pages@2/flying-pages.min.js
|
|
535
539
|
|
|
540
|
+
# pjax - 无刷新加载
|
|
541
|
+
# 启用后点击链接将使用 AJAX 加载内容,无需整页刷新
|
|
542
|
+
pjax:
|
|
543
|
+
enable: false # 还在测试中,可能存在兼容问题
|
|
544
|
+
selectors: ['title', '#l_cover', '.l_body'] # 需要替换的元素选择器
|
|
545
|
+
timeout: 10000 # 请求超时时间(毫秒)
|
|
546
|
+
cacheBust: false # 是否添加时间戳防止缓存
|
|
547
|
+
translate-distance: 8px # 动画
|
|
548
|
+
|
|
536
549
|
# https://fancyapps.com/docs/ui/fancybox/
|
|
537
550
|
# available for {% image xxx %}
|
|
538
551
|
fancybox:
|
|
539
552
|
enable: true
|
|
540
|
-
loader: /js/plugins/fancybox-loader.js
|
|
541
553
|
js: https://gcore.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js
|
|
542
554
|
css: https://gcore.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css
|
|
543
555
|
# 让 md 语法图片支持放大可以这样写: .md-text img:not([class]), .md-text .image img
|
|
@@ -557,8 +569,8 @@ plugins:
|
|
|
557
569
|
enable: #true # 慎用,有些时候打开页面空白
|
|
558
570
|
js: https://gcore.jsdelivr.net/npm/scrollreveal@4.0/dist/scrollreveal.min.js
|
|
559
571
|
distance: 8px
|
|
560
|
-
duration:
|
|
561
|
-
interval:
|
|
572
|
+
duration: 1000 # ms
|
|
573
|
+
interval: 100 # ms
|
|
562
574
|
scale: 1 # 0.1~1
|
|
563
575
|
|
|
564
576
|
# AI 摘要
|
|
@@ -588,12 +600,13 @@ plugins:
|
|
|
588
600
|
katex:
|
|
589
601
|
enable: #true # hexo-renderer-markdown-it-plus 默认开启 katex,此选项仅用于引入样式
|
|
590
602
|
inject: |
|
|
591
|
-
<link rel="stylesheet" href="https://
|
|
592
|
-
|
|
603
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.23/dist/katex.min.css" integrity="sha384-//SZkxyB7axjCAopkAL1E1rve+ZSPKapD89Lo/lLhcsXR+zOYl5z6zJZEFXil+q0" crossorigin="anonymous">
|
|
604
|
+
|
|
593
605
|
# MathJax
|
|
594
606
|
# 需在Markdown文件开头加入mathjax: true
|
|
595
607
|
# 推荐使用Pandoc: npm uninstall hexo-renderer-marked --save & npm install hexo-renderer-pandoc --save
|
|
596
608
|
mathjax:
|
|
609
|
+
v3: false # 若使用 v3,需將 js 設置為 https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.min.js
|
|
597
610
|
enable: # true # 可以在特定文章的 front-matter 中设置 mathjax: true 来开启,也可以在这里设置全局开启
|
|
598
611
|
js: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML
|
|
599
612
|
|
|
@@ -654,16 +667,10 @@ style:
|
|
|
654
667
|
image: 16px # 技术类文章插图圆角
|
|
655
668
|
image-s: 8px # 评论区图片圆角(部分评论支持)
|
|
656
669
|
color:
|
|
657
|
-
# 动态颜色(会根据明暗主题重设明度值,只用关心色相和饱和度即可)
|
|
658
|
-
background: 'hsl(212 16% 98%)' # 浅色背景颜色
|
|
659
|
-
block: 'hsl(212 8% 95%)' # 块背景颜色
|
|
660
|
-
code: 'hsl(220 20% 10%)' # 'hsl(14 100% 48%)' # 行内代码颜色
|
|
661
|
-
text: 'hsl(0 0% 20%)' # 文本颜色
|
|
662
670
|
# 主题色配置(不会根据明暗动态调整,请设置为通用的颜色)
|
|
663
671
|
theme: 'hsl(192 98% 55%)' # 主题色
|
|
664
672
|
accent: 'hsl(14 100% 57%)' # 强调色
|
|
665
673
|
link: 'hsl(207 90% 54%)' # 超链接颜色
|
|
666
|
-
hover: 'hsl(14 100% 57%)' # 按钮高亮颜色
|
|
667
674
|
animated_avatar:
|
|
668
675
|
animate: auto # auto, always
|
|
669
676
|
background: https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/avatar/round/rainbow64@3x.webp
|
|
@@ -677,7 +684,9 @@ style:
|
|
|
677
684
|
start: 'linear-gradient(to right, hsl(215, 95%, 64%), hsl(195, 95%, 60%), hsl(165, 95%, 56%), hsl(165, 95%, 56%), hsl(195 95% 60%), hsl(215, 95%, 64%))'
|
|
678
685
|
leftbar:
|
|
679
686
|
# 可以设置:纯色/渐变色/图片作为背景
|
|
680
|
-
|
|
687
|
+
# 设置为纯色时,可以分别设置浅色和深色模式背景色
|
|
688
|
+
background-color-light: var(--card) # var(--block) #'rgb(#C3C3C3)'
|
|
689
|
+
background-color-dark: var(--card) # var(--block) #'rgb(#3C3C3C)'
|
|
681
690
|
background-image: url(https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.13/image/sidebar-bg1@small.jpg)
|
|
682
691
|
blur-px: 100px
|
|
683
692
|
blur-bg: var(--bg-a60)
|
|
@@ -693,7 +702,7 @@ style:
|
|
|
693
702
|
blur-sat: 300%
|
|
694
703
|
# 技术文章内页各级标题前面的符号
|
|
695
704
|
header_prefix:
|
|
696
|
-
h2: '
|
|
705
|
+
h2: '#'
|
|
697
706
|
h3: '='
|
|
698
707
|
h4: '|'
|
|
699
708
|
h5: ':'
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# Stellar 主题及 xaoxuu.com 项目全面分析报告
|
|
2
|
+
|
|
3
|
+
> 审计日期:2026-08-08 | 版本:hexo-theme-stellar v1.33.1 | Hexo 7.0.0
|
|
4
|
+
|
|
5
|
+
## 一、项目概览
|
|
6
|
+
|
|
7
|
+
| 维度 | 详情 |
|
|
8
|
+
|------|------|
|
|
9
|
+
| **站点** | `xaoxuu.com` 个人博客,Hexo 7.0.0 |
|
|
10
|
+
| **主题** | `hexo-theme-stellar` v1.33.1(Git 子模块) |
|
|
11
|
+
| **部署** | GitHub Actions → gh-pages + Vercel 边缘 |
|
|
12
|
+
| **模板引擎** | EJS + Stylus |
|
|
13
|
+
| **内容规模** | ~100 篇文章(2013-2026),wiki 文档、笔记系统 |
|
|
14
|
+
| **语言** | zh-CN / en / zh-TW 多语言 |
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 二、高优先级问题清单(按紧急程度排序)
|
|
19
|
+
|
|
20
|
+
### P0 - 阻塞性/安全性问题
|
|
21
|
+
|
|
22
|
+
#### 问题 1:缺少安全响应头(CSP / X-Frame-Options / X-Content-Type-Options)
|
|
23
|
+
|
|
24
|
+
**场景**:当前 HTML 响应头中未设置任何安全策略头,站点对所有浏览器默认攻击面完全暴露。
|
|
25
|
+
|
|
26
|
+
**影响范围**:全局,所有页面。
|
|
27
|
+
|
|
28
|
+
**根因**:`layout/_partial/head.ejs` 模板中没有添加安全头部,`vercel.json` 也仅配置了缓存策略。
|
|
29
|
+
|
|
30
|
+
**修复方向**:
|
|
31
|
+
1. 在 `layout/_partial/head.ejs` 中添加 `<meta http-equiv>` 级别的基础安全策略(作为最低保障)
|
|
32
|
+
2. 在 `vercel.json` 中添加 `Content-Security-Policy`、`X-Frame-Options: DENY`、`X-Content-Type-Options: nosniff` 响应头
|
|
33
|
+
|
|
34
|
+
**复杂度**:低 | **建议时间**:1 周内
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
#### 问题 2:Tag 插件存在 XSS 注入风险
|
|
39
|
+
|
|
40
|
+
**场景**:多个 tag 插件在渲染用户可控内容(`alt`、`title`、`url` 参数)时直接拼接到 HTML 属性中,未做转义处理。
|
|
41
|
+
|
|
42
|
+
**影响范围**:所有使用 tag 插件的页面。若结合友链等用户贡献内容存在被注入风险。
|
|
43
|
+
|
|
44
|
+
**具体位置**:
|
|
45
|
+
|
|
46
|
+
| 文件 | 行号 | 风险参数 |
|
|
47
|
+
|------|------|----------|
|
|
48
|
+
| `scripts/tags/lib/image.js` | L45 | `alt` 直接拼接 |
|
|
49
|
+
| `scripts/tags/lib/frame.js` | L61 | `alt` 直接拼接 |
|
|
50
|
+
| `scripts/tags/lib/folding.js` | L23 | `title` 通过 markdown 渲染但未过滤 HTML 标签 |
|
|
51
|
+
| `scripts/tags/lib/link.js` | L52 | `title` 直接拼接 |
|
|
52
|
+
|
|
53
|
+
**修复方向**:对所有用户可控的输出进行 `escape_html` 或等效转义处理后再嵌入 HTML。
|
|
54
|
+
|
|
55
|
+
**复杂度**:中 | **建议时间**:2 周内
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
#### 问题 3:`glob` 依赖未声明导致构建可能失败
|
|
60
|
+
|
|
61
|
+
**场景**:`scripts/events/lib/get_image_ratios.js` L3 中 `require('glob')` 引入了 `glob` 包,但该包未在主题 `package.json` 或站点 `package.json` 中声明为依赖。当前能运行是因为 `gulp` 的传递依赖中存在 glob,但这是一个脆弱的巧合。
|
|
62
|
+
|
|
63
|
+
**影响范围**:启用 `lazyload.fix_ratio` 功能的 `hexo server` 模式。在全新 `npm install --production` 环境下必然失败。
|
|
64
|
+
|
|
65
|
+
**修复方向**:在 `themes/stellar/package.json` 的 `dependencies` 中添加 `"glob": "^10.x"`。
|
|
66
|
+
|
|
67
|
+
**复杂度**:低 | **建议时间**:1 周内
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### P1 - 严重影响可用性
|
|
72
|
+
|
|
73
|
+
#### 问题 4:GitHub Actions 使用已弃用的 Node 16 actions
|
|
74
|
+
|
|
75
|
+
**场景**:`.github/workflows/auto-deploy.yml` 中 `actions/checkout@v3` (L15) 和 `peaceiris/actions-gh-pages@v3` (L29) 均依赖 Node.js 16,GitHub 已宣布逐步弃用。
|
|
76
|
+
|
|
77
|
+
**影响范围**:CI 自动部署流程将中断。
|
|
78
|
+
|
|
79
|
+
**修复方向**:升级 `actions/checkout@v4` 和 `peaceiris/actions-gh-pages@v4`。
|
|
80
|
+
|
|
81
|
+
**复杂度**:低 | **建议时间**:1 周内
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
#### 问题 5:`document.execCommand("Copy")` 已弃用
|
|
86
|
+
|
|
87
|
+
**场景**:`source/js/main.js` L40 中使用 `document.execCommand("Copy")` 实现复制功能,该 API 已被 W3C 标记为废弃,主流浏览器未来版本将移除。
|
|
88
|
+
|
|
89
|
+
**影响范围**:所有页面的「复制代码」功能。
|
|
90
|
+
|
|
91
|
+
**修复方向**:迁移到 `navigator.clipboard.writeText()` API。
|
|
92
|
+
|
|
93
|
+
**复杂度**:低 | **建议时间**:2 周内
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
#### 问题 6:构建后缺少 JS/CSS 压缩步骤
|
|
98
|
+
|
|
99
|
+
**场景**:CI 流水线(`.github/workflows/auto-deploy.yml`)仅执行 `hexo generate`,未运行 gulpfile 中的 JS/CSS/HTML 压缩任务。而 `gulpfile.js` 配置了完整的压缩流程(babel + terser + cleanCSS + htmlmin)。
|
|
100
|
+
|
|
101
|
+
**影响范围**:生产环境部署的静态资源未经压缩,JS 文件体积较大,直接影响首屏加载速度。
|
|
102
|
+
|
|
103
|
+
**修复方向**:在 CI 的 "Generate Public Files" 步骤后、部署前添加 `npx gulp minify`。
|
|
104
|
+
|
|
105
|
+
**复杂度**:低 | **建议时间**:1 周内
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
#### 问题 7:首屏加载阻塞 — jQuery 和 Marked 同步加载
|
|
110
|
+
|
|
111
|
+
**场景**:CSS 采用同步 `<link>` 加载(`layout/_partial/head.ejs` L190),jQuery(3.7)和 Marked(13.0)虽然以 `defer` 方式加载(`layout/_partial/scripts.ejs` L25),但 CSS 阻塞渲染的问题仍然存在,且大量 CDN 依赖增加了网络往返次数。
|
|
112
|
+
|
|
113
|
+
**影响范围**:首屏加载时间可能超过 3 秒(尤其在 CDN 网络抖动时)。
|
|
114
|
+
|
|
115
|
+
**修复方向**:
|
|
116
|
+
1. 将非首屏必需的 CSS 延迟加载
|
|
117
|
+
2. 考虑将核心 CSS 内联到 `<head>` 中
|
|
118
|
+
3. 为 CDN 资源添加 `dns-prefetch`(已部分实现 preconnect)
|
|
119
|
+
|
|
120
|
+
**复杂度**:中 | **建议时间**:1 个月内
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### P2 - 阻碍主题迭代
|
|
125
|
+
|
|
126
|
+
#### 问题 8:无测试覆盖
|
|
127
|
+
|
|
128
|
+
**场景**:主题 `package.json` 中 `"test": "echo test"`,零测试覆盖。tag 插件多达 40+ 个,任何修改都可能引入回归。
|
|
129
|
+
|
|
130
|
+
**影响范围**:主题维护效率低,发布后经常出现回归问题。
|
|
131
|
+
|
|
132
|
+
**修复方向**:至少为核心 tag 插件、配置合并逻辑、URL 生成逻辑添加单元测试。推荐使用 mocha + chai。
|
|
133
|
+
|
|
134
|
+
**复杂度**:高 | **建议时间**:3 个月内逐步覆盖
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
#### 问题 9:大型内联 SVG 造成代码膨胀
|
|
139
|
+
|
|
140
|
+
**场景**:`scripts/tags/lib/chat.js` 文件 ~517 行中包含大量内联 SVG 数据(浏览器图标 ~10 个、文件类型图标 ~15 个),使得 tag 插件脚本体积显著增大。
|
|
141
|
+
|
|
142
|
+
**影响范围**:每次 hexo generate 时都会加载这些数据到内存,构建性能受影响。
|
|
143
|
+
|
|
144
|
+
**修复方向**:将 SVG 数据外置到独立 JSON/YAML 文件,通过 `require` 引用。
|
|
145
|
+
|
|
146
|
+
**复杂度**:低 | **建议时间**:1 个月内
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
#### 问题 10:主题内 `hexo-fs` 依赖未声明且未使用
|
|
151
|
+
|
|
152
|
+
**场景**:`scripts/filters/lib/img_onerror.js` L8 中 `const fs = require('hexo-fs')` 声明了变量但未实际使用(该函数只用到 `this.theme.config.default.image`)。
|
|
153
|
+
|
|
154
|
+
**影响范围**:轻微性能影响,且若 `hexo-fs` 在未来版本中行为变化可能引入问题。
|
|
155
|
+
|
|
156
|
+
**修复方向**:移除未使用的 `require('hexo-fs')`。
|
|
157
|
+
|
|
158
|
+
**复杂度**:低 | **建议时间**:1 周内
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### P3 - 生产环境潜在风险
|
|
163
|
+
|
|
164
|
+
#### 问题 11:无站点监控/告警机制
|
|
165
|
+
|
|
166
|
+
**场景**:当前仅靠 GitHub Actions 构建成功后 curl 触发服务器更新。无任何可用性监控、无错误追踪、无流量异常告警。
|
|
167
|
+
|
|
168
|
+
**影响范围**:站点故障时依赖用户反馈,恢复时间不可控。
|
|
169
|
+
|
|
170
|
+
**修复方向**:接入 UptimeRobot 或类似免费监控服务,配置宕机告警。
|
|
171
|
+
|
|
172
|
+
**复杂度**:低 | **建议时间**:2 周内
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
#### 问题 12:`hexo-all-minifier` 安装但未启用
|
|
177
|
+
|
|
178
|
+
**场景**:站点 `package.json` 中安装了 `hexo-all-minifier`,但 `_config.yml` 中 `all_minifier: false`。如果意外启用,可能和 gulp 压缩产生冲突。
|
|
179
|
+
|
|
180
|
+
**修复方向**:若已使用 gulp 替代,应移除该依赖。
|
|
181
|
+
|
|
182
|
+
**复杂度**:低 | **建议时间**:按需
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 三、快速修复建议(按工作量排序)
|
|
187
|
+
|
|
188
|
+
| # | 问题 | 工作量 |
|
|
189
|
+
|---|------|--------|
|
|
190
|
+
| 1 | 移除 `img_onerror.js` 中未使用的 `hexo-fs` require | 5 min ~~已修复~~ |
|
|
191
|
+
| 2 | 添加 `glob` 到 theme package.json dependencies | 5 min ~~已修复~~ |
|
|
192
|
+
| 3 | 添加安全响应头 (vercel.json) | 15 min ~~已修复~~ |
|
|
193
|
+
| 4 | 升级 GitHub Actions (`checkout@v4`, `gh-pages@v4`) | 5 min ~~已修复~~ |
|
|
194
|
+
| 5 | 替换 `execCommand` 为 `navigator.clipboard` | 30 min ~~已修复~~ |
|
|
195
|
+
| 6 | CI 中加入 `npx gulp minify` 步骤 | 10 min ~~已修复~~ |
|
|
196
|
+
| 7 | Tag 插件 HTML 转义修复 | 2-4 h ~~已修复~~ |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 四、主题 Stellar 后续核心优化方向
|
|
201
|
+
|
|
202
|
+
| 方向 | 说明 | 优先级 |
|
|
203
|
+
|------|------|--------|
|
|
204
|
+
| **安全加固** | 添加 CSP 头、全量审查 tag 插件 HTML 输出转义 | 高 |
|
|
205
|
+
| **性能优化** | CDN 依赖瘦身、CSS/JS 代码分割、字体子集化 | 高 |
|
|
206
|
+
| **测试覆盖** | 建立 CI 测试流水线、核心功能回归测试 | 高 |
|
|
207
|
+
| **Hexo 7+ 适配** | 验证所有 API 在 Hexo 7.x 下的兼容性 | 中 |
|
|
208
|
+
| **PJAX 稳定化** | 完成 pjax 模式的兼容性修复并正式发布 | 中 |
|
|
209
|
+
| **TypeScript 迁移** | 将 scripts/ 下 JS 逐步迁移到 TS,提升可维护性 | 低 |
|
|
210
|
+
| **无障碍 (a11y)** | 检查 ARIA 标签、键盘导航支持 | 低 |
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 五、技术栈与依赖清单
|
|
215
|
+
|
|
216
|
+
### 站点 package.json
|
|
217
|
+
|
|
218
|
+
| 依赖 | 版本 | 用途 |
|
|
219
|
+
|------|------|------|
|
|
220
|
+
| hexo | ^7.0.0 | 静态站点生成器 |
|
|
221
|
+
| hexo-all-minifier | ^0.5.7 | 资源压缩(未启用) |
|
|
222
|
+
| hexo-autonofollow | ^1.0.1 | 外链 nofollow |
|
|
223
|
+
| hexo-deployer-git | ^4.0.0 | Git 部署 |
|
|
224
|
+
| hexo-generator-feed | ^3.0.0 | RSS/Atom Feed |
|
|
225
|
+
| hexo-generator-seo-friendly-sitemap | ^0.2.1 | SEO 站点地图 |
|
|
226
|
+
| hexo-renderer-ejs | ^2.0.0 | EJS 渲染器 |
|
|
227
|
+
| hexo-renderer-marked | ^6.2.0 | Markdown 渲染器 |
|
|
228
|
+
| hexo-renderer-stylus | ^3.0.1 | Stylus CSS 预处理器 |
|
|
229
|
+
|
|
230
|
+
### 主题 package.json
|
|
231
|
+
|
|
232
|
+
| 依赖 | 版本 | 用途 |
|
|
233
|
+
|------|------|------|
|
|
234
|
+
| cheerio | ^1.1.0 | HTML 解析 |
|
|
235
|
+
| hexo-renderer-ejs | ^2.0.0 | EJS 渲染 |
|
|
236
|
+
| hexo-renderer-stylus | ^3.0.1 | Stylus 渲染 |
|
|
237
|
+
| probe-image-size | ^7.2.3 | 图片尺寸探测 |
|
|
238
|
+
| glob(缺失) | - | 文件匹配(get_image_ratios.js) |
|
|
239
|
+
|
|
240
|
+
### 部署架构
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
GitHub Push → GitHub Actions (auto-deploy.yml)
|
|
244
|
+
├─ checkout + submodules
|
|
245
|
+
├─ npm i + hexo generate
|
|
246
|
+
├─ deploy to gh-pages (peaceiris/actions-gh-pages)
|
|
247
|
+
└─ curl hook → 服务器 pull 更新
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### CDN 资源依赖
|
|
251
|
+
|
|
252
|
+
| 资源 | CDN |
|
|
253
|
+
|------|-----|
|
|
254
|
+
| jQuery 3.7 | gcore.jsdelivr.net |
|
|
255
|
+
| Marked 13.0 | gcore.jsdelivr.net |
|
|
256
|
+
| Vanilla Lazyload 19.1 | gcore.jsdelivr.net |
|
|
257
|
+
| Fancybox UI 5.0 | gcore.jsdelivr.net |
|
|
258
|
+
| Swiper 10.3 | unpkg.com |
|
|
259
|
+
| KaTeX 0.16.23 | cdn.jsdelivr.net |
|
|
260
|
+
| MathJax 2.7.6 | cdnjs.cloudflare.com |
|
|
261
|
+
| Mermaid v9 | gcore.jsdelivr.net |
|
|
262
|
+
| Flying Pages 2 | gcore.jsdelivr.net |
|
|
263
|
+
| Highlight.js 11.9 | gcore.jsdelivr.net |
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
*报告生成时间:2026-08-08 | 分析工具:人工代码审查 + npm audit*
|