@windcoder/astro-theme-orchid 0.2.0 → 0.3.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/README.md +6 -4
- package/package.json +9 -5
- package/scripts/check-friends.mjs +227 -0
- package/scripts/generate-lqips.mjs +83 -0
- package/scripts/migrate-posts.mjs +375 -0
- package/scripts/subset-fonts.mjs +227 -0
- package/src/components/Analytics.astro +3 -0
- package/src/components/BaseLayout.astro +40 -1
- package/src/components/analytics/WebVitals.astro +72 -0
- package/src/i18n/en.ts +9 -0
- package/src/i18n/zh-CN.ts +9 -0
- package/src/index.ts +23 -2
- package/src/plugins/rehype.ts +48 -2
- package/src/routes/bangumi.astro +110 -0
- package/src/routes/categories/[category]/[...page].astro +53 -0
- package/src/routes/manifest.webmanifest.ts +33 -0
- package/src/routes/moments/[...page].astro +80 -0
- package/src/routes/rss.xml.ts +41 -14
- package/src/routes/sw.js.ts +127 -0
- package/src/routes/tags/[tag]/[...page].astro +51 -0
- package/src/schema.ts +154 -1
- package/src/styles/global.css +201 -0
- package/src/routes/categories/[category].astro +0 -37
- package/src/routes/tags/[tag].astro +0 -40
package/README.md
CHANGED
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
## 特性一览
|
|
6
6
|
|
|
7
|
-
- **页面**:首页(featured/cover/compact/text 四种卡片混排)、文章页(TOC
|
|
7
|
+
- **页面**:首页(featured/cover/compact/text 四种卡片混排)、文章页(TOC/相关推荐/分享海报/打赏入口)、归档(按年折叠)、分类、标签、专题、画廊(含加密相册)、友链、追番、留言板、打赏、关于
|
|
8
8
|
- **写作增强**:LaTeX(KaTeX + mhchem)、Mermaid 双主题、PlantUML、Callouts、GitHub 卡片、图语法(figure/九宫格)、Expressive Code 代码块(双主题/行号/折叠/复制/语言徽标)、邮箱防爬
|
|
9
9
|
- **互动系统**:评论五套(Artalk / Twikoo / Waline / Giscus / Disqus)、文章加密、过时提醒、公告、广告位
|
|
10
10
|
- **个性化**:深浅模式、hue 动态调色、樱花飘落、背景壁纸、音乐播放器(跨页不断播)、Live2D 看板娘、i18n(zh-CN / en)
|
|
11
|
-
- **工程化**:配置启动即校验(Zod)、OG 分享图、LQIP 占位、字体子集化、站点统计四件套(GA / Clarity / Umami / 51.la)、RSS / sitemap
|
|
11
|
+
- **工程化**:配置启动即校验(Zod)、OG 分享图、LQIP 占位、字体子集化、站点统计四件套(GA / Clarity / Umami / 51.la)、RSS / sitemap、PWA 可安装(manifest + 离线兜底 Service Worker)
|
|
12
12
|
|
|
13
13
|
## 快速上手
|
|
14
14
|
|
|
15
|
+
> 新站点推荐直接从 [astro-theme-orchid-starter](https://github.com/iwinder/astro-theme-orchid-starter) 模板生成(Use this template),配置与内容骨架开箱即用;以下为在已有 Astro 站点上接入主题的步骤。
|
|
16
|
+
|
|
15
17
|
### 1. 安装
|
|
16
18
|
|
|
17
19
|
```sh
|
|
@@ -78,8 +80,8 @@ site/
|
|
|
78
80
|
|
|
79
81
|
完整配置说明与文章 frontmatter 全字段表统一放在 demo 站「主题使用指南」系列文章(源文件在本仓库 `site/src/content/posts/`),按主题分组:
|
|
80
82
|
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
+
- 基础:《站点基础配置》|《导航栏》|《首页横幅》|《侧边栏与小组件》|《个人资料卡》|《版权声明》|《文章列表与归档》
|
|
84
|
+
- 功能:《文章页功能》|《内容渲染》|《樱花特效》|《音乐播放器》|《Live2D 看板娘》|《字体》|《评论系统》|《公告》|《站点统计》|《广告位》|《友链》|《追番》|《PWA》|《赞助》|《画廊》|《独立页面》
|
|
83
85
|
- 写作:《写作指南》(frontmatter 全字段与增强语法)|《MDX 指南》(MDX 启用与踩坑修复)
|
|
84
86
|
|
|
85
87
|
## 定制与覆盖
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windcoder/astro-theme-orchid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "清新简约的 Astro 博客主题,以 Integration 形式提供,支持版本化升级与组件覆盖",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"./styles/*": "./src/styles/*"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
|
-
"src"
|
|
34
|
+
"src",
|
|
35
|
+
"scripts",
|
|
36
|
+
"!scripts/*.test.mjs"
|
|
35
37
|
],
|
|
36
38
|
"peerDependencies": {
|
|
37
39
|
"@iconify-json/lucide": "^1.2.0",
|
|
@@ -61,11 +63,13 @@
|
|
|
61
63
|
"remark-math": "^6.0.0",
|
|
62
64
|
"satori": "^0.47.1",
|
|
63
65
|
"sharp": "^0.35.5",
|
|
64
|
-
"
|
|
66
|
+
"subset-font": "^2.5.0",
|
|
67
|
+
"tailwindcss": "^4.3.2",
|
|
68
|
+
"web-vitals": "^6.2.3",
|
|
69
|
+
"yaml": "^2.9.1"
|
|
65
70
|
},
|
|
66
71
|
"devDependencies": {
|
|
67
72
|
"@types/pako": "^2.0.3",
|
|
68
|
-
"@types/qrcode": "^1.5.6"
|
|
69
|
-
"subset-font": "^2.5.0"
|
|
73
|
+
"@types/qrcode": "^1.5.6"
|
|
70
74
|
}
|
|
71
75
|
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 友链存活检测(§4.90):读取构建产物 dist/friends/index.html,抽取友链卡片
|
|
4
|
+
* (a.friend-card + .friend-name),并发探测各站点可达性,输出检测报告。
|
|
5
|
+
*
|
|
6
|
+
* 设计为发布后/定时(CI cron)手动运行,不挂进 build——构建保持离线可复现。
|
|
7
|
+
*
|
|
8
|
+
* 用法(站点根目录):
|
|
9
|
+
* node node_modules/@windcoder/astro-theme-orchid/scripts/check-friends.mjs \
|
|
10
|
+
* [--dist dist] [--timeout 8000] [--retries 1] [--concurrency 6] \
|
|
11
|
+
* [--json report.json] [--fail-on-dead]
|
|
12
|
+
*
|
|
13
|
+
* 判级:ok = 2xx/3xx;warn = 403/405/406/429/999(常见反爬拦截,未必失联);
|
|
14
|
+
* dead = 网络层失败(解析/超时/拒绝)与其余 4xx/5xx。网络层失败与 5xx 重试。
|
|
15
|
+
*/
|
|
16
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { resolve } from "node:path";
|
|
18
|
+
import { pathToFileURL } from "node:url";
|
|
19
|
+
|
|
20
|
+
const UA =
|
|
21
|
+
"Mozilla/5.0 (compatible; OrchidFriendChecker/+https://github.com/iwinder/qy-astro-theme-orchid)";
|
|
22
|
+
/** 这些状态码通常是 WAF/反爬拦截而非失联,只警告不定罪 */
|
|
23
|
+
const WARN_CODES = new Set([403, 405, 406, 429, 999]);
|
|
24
|
+
|
|
25
|
+
function parseArgs(argv) {
|
|
26
|
+
const args = {
|
|
27
|
+
dist: "dist",
|
|
28
|
+
timeout: 8000,
|
|
29
|
+
retries: 1,
|
|
30
|
+
concurrency: 6,
|
|
31
|
+
json: "",
|
|
32
|
+
failOnDead: false,
|
|
33
|
+
};
|
|
34
|
+
for (let i = 0; i < argv.length; i++) {
|
|
35
|
+
const a = argv[i];
|
|
36
|
+
if (a === "--dist") args.dist = argv[++i];
|
|
37
|
+
else if (a === "--timeout") args.timeout = Number(argv[++i]);
|
|
38
|
+
else if (a === "--retries") args.retries = Number(argv[++i]);
|
|
39
|
+
else if (a === "--concurrency") args.concurrency = Number(argv[++i]);
|
|
40
|
+
else if (a === "--json") args.json = argv[++i];
|
|
41
|
+
else if (a === "--fail-on-dead") args.failOnDead = true;
|
|
42
|
+
else if (a === "--help" || a === "-h") {
|
|
43
|
+
console.log(
|
|
44
|
+
"用法:node check-friends.mjs [--dist dist] [--timeout 8000] [--retries 1] [--concurrency 6] [--json report.json] [--fail-on-dead]",
|
|
45
|
+
);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return args;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function decodeEntities(s) {
|
|
53
|
+
return s
|
|
54
|
+
.replace(/&/g, "&")
|
|
55
|
+
.replace(/</g, "<")
|
|
56
|
+
.replace(/>/g, ">")
|
|
57
|
+
.replace(/"/g, '"')
|
|
58
|
+
.replace(/'/g, "'");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 从友链页 HTML 抽取 [{ title, url }](主题自有标记,结构稳定) */
|
|
62
|
+
export function extractFriends(html) {
|
|
63
|
+
const out = [];
|
|
64
|
+
const re =
|
|
65
|
+
/<a class="friend-card card" href="([^"]+)"[\s\S]*?<div class="friend-name">([\s\S]*?)<\/div>/g;
|
|
66
|
+
let m;
|
|
67
|
+
while (true) {
|
|
68
|
+
m = re.exec(html);
|
|
69
|
+
if (!m) break;
|
|
70
|
+
out.push({
|
|
71
|
+
url: decodeEntities(m[1]),
|
|
72
|
+
title: decodeEntities(m[2].replace(/<[^>]+>/g, "")).trim(),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** HTTP 状态码 → ok/warn/dead 判级(0 = 网络层失败) */
|
|
79
|
+
export function classify(code) {
|
|
80
|
+
if (code === 0) return "dead";
|
|
81
|
+
if (code >= 200 && code < 400) return "ok";
|
|
82
|
+
if (WARN_CODES.has(code)) return "warn";
|
|
83
|
+
return "dead";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 单次探测:GET + 超时 + 立即丢弃响应体(只看状态码) */
|
|
87
|
+
async function probeOnce(url, timeout) {
|
|
88
|
+
const started = Date.now();
|
|
89
|
+
try {
|
|
90
|
+
const res = await fetch(url, {
|
|
91
|
+
redirect: "follow",
|
|
92
|
+
signal: AbortSignal.timeout(timeout),
|
|
93
|
+
headers: { "user-agent": UA, accept: "text/html,*/*;q=0.8" },
|
|
94
|
+
});
|
|
95
|
+
res.body?.cancel().catch(() => {});
|
|
96
|
+
return { code: res.status, ms: Date.now() - started, msg: "" };
|
|
97
|
+
} catch (err) {
|
|
98
|
+
const cause = err?.cause?.code ?? err?.code ?? "";
|
|
99
|
+
const msg =
|
|
100
|
+
err?.name === "TimeoutError" || err?.name === "AbortError"
|
|
101
|
+
? "超时"
|
|
102
|
+
: cause === "ENOTFOUND" || cause === "EAI_AGAIN"
|
|
103
|
+
? "域名无法解析"
|
|
104
|
+
: cause === "ECONNREFUSED"
|
|
105
|
+
? "连接被拒绝"
|
|
106
|
+
: cause === "ECONNRESET"
|
|
107
|
+
? "连接被重置"
|
|
108
|
+
: cause === "CERT_HAS_EXPIRED" ||
|
|
109
|
+
cause === "UNABLE_TO_VERIFY_LEAF_SIGNATURE"
|
|
110
|
+
? "证书异常"
|
|
111
|
+
: String(cause || err?.message || err);
|
|
112
|
+
return { code: 0, ms: Date.now() - started, msg };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** 带重试探测:网络层失败与 5xx 重试(4xx 定局重试无意义) */
|
|
117
|
+
export async function probe(url, { timeout, retries }) {
|
|
118
|
+
let last = await probeOnce(url, timeout);
|
|
119
|
+
for (let i = 0; i < retries && (last.code === 0 || last.code >= 500); i++) {
|
|
120
|
+
last = await probeOnce(url, timeout);
|
|
121
|
+
}
|
|
122
|
+
return { ...last, state: classify(last.code) };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** CJK 感知的终端定宽 */
|
|
126
|
+
function pad(s, width) {
|
|
127
|
+
let visual = 0;
|
|
128
|
+
for (const ch of s) visual += ch.codePointAt(0) > 0xff ? 2 : 1;
|
|
129
|
+
return visual >= width ? s : s + " ".repeat(width - visual);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function main() {
|
|
133
|
+
const args = parseArgs(process.argv.slice(2));
|
|
134
|
+
const pagePath = resolve(args.dist, "friends", "index.html");
|
|
135
|
+
let html;
|
|
136
|
+
try {
|
|
137
|
+
html = readFileSync(pagePath, "utf8");
|
|
138
|
+
} catch {
|
|
139
|
+
console.error(
|
|
140
|
+
`[check-friends] 找不到 ${pagePath}\n 友链页未开启(pages.friends: false)或尚未构建;先 pnpm build 再检测。`,
|
|
141
|
+
);
|
|
142
|
+
process.exit(0);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const friends = extractFriends(html);
|
|
146
|
+
if (!friends.length) {
|
|
147
|
+
console.log("[check-friends] 友链页无友链卡片,无事可做。");
|
|
148
|
+
process.exit(0);
|
|
149
|
+
}
|
|
150
|
+
console.log(
|
|
151
|
+
`[check-friends] 共 ${friends.length} 条友链,并发 ${args.concurrency},超时 ${args.timeout}ms,重试 ${args.retries} 次\n`,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const results = new Array(friends.length);
|
|
155
|
+
let cursor = 0;
|
|
156
|
+
async function worker() {
|
|
157
|
+
while (cursor < friends.length) {
|
|
158
|
+
const idx = cursor++;
|
|
159
|
+
const { url, title } = friends[idx];
|
|
160
|
+
process.stdout.write(` 探测 ${title} …\r`);
|
|
161
|
+
const r = await probe(url, args);
|
|
162
|
+
results[idx] = { ...r, title, url };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
await Promise.all(
|
|
166
|
+
Array.from({ length: Math.min(args.concurrency, friends.length) }, worker),
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const ICON = { ok: "✓", warn: "⚠", dead: "✗" };
|
|
170
|
+
console.log(
|
|
171
|
+
"\n┌────┬──────┬────────┬────────┬──────────────────────┬──────────────────────────────────────┐",
|
|
172
|
+
);
|
|
173
|
+
console.log(
|
|
174
|
+
`│ ${pad("状态", 2)} │ ${pad("站点", 18)} │ ${pad("HTTP", 6)} │ ${pad("耗时", 6)} │ ${pad("说明", 20)} │ 链接`,
|
|
175
|
+
);
|
|
176
|
+
console.log(
|
|
177
|
+
"├────┼──────┼────────┼────────┼──────────────────────┼──────────────────────────────────────┤",
|
|
178
|
+
);
|
|
179
|
+
for (const r of results) {
|
|
180
|
+
const note = r.state === "warn" ? "疑似反爬拦截,请人工复核" : r.msg;
|
|
181
|
+
console.log(
|
|
182
|
+
`│ ${ICON[r.state]} │ ${pad(r.title, 18)} │ ${pad(String(r.code || "-"), 6)} │ ${pad(`${r.ms}ms`, 6)} │ ${pad(note, 20)} │ ${r.url}`,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
console.log(
|
|
186
|
+
"└────┴──────┴────────┴────────┴──────────────────────┴──────────────────────────────────────┘",
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const ok = results.filter((r) => r.state === "ok").length;
|
|
190
|
+
const warn = results.filter((r) => r.state === "warn").length;
|
|
191
|
+
const dead = results.filter((r) => r.state === "dead").length;
|
|
192
|
+
console.log(`\n[check-friends] 完成:ok ${ok} / warn ${warn} / dead ${dead}`);
|
|
193
|
+
if (warn)
|
|
194
|
+
console.log(
|
|
195
|
+
" ⚠ warn 为常见反爬状态码(403/405/406/429/999),浏览器开一下再决定是否下架",
|
|
196
|
+
);
|
|
197
|
+
if (dead) {
|
|
198
|
+
for (const r of results.filter((x) => x.state === "dead"))
|
|
199
|
+
console.log(` ✗ ${r.title} <${r.url}> ${r.msg || `HTTP ${r.code}`}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (args.json) {
|
|
203
|
+
const report = {
|
|
204
|
+
checkedAt: new Date().toISOString(),
|
|
205
|
+
total: friends.length,
|
|
206
|
+
ok,
|
|
207
|
+
warn,
|
|
208
|
+
dead,
|
|
209
|
+
results: results.map(({ title, url, state, code, ms, msg }) => ({
|
|
210
|
+
title,
|
|
211
|
+
url,
|
|
212
|
+
state,
|
|
213
|
+
code,
|
|
214
|
+
ms,
|
|
215
|
+
msg,
|
|
216
|
+
})),
|
|
217
|
+
};
|
|
218
|
+
writeFileSync(resolve(args.json), `${JSON.stringify(report, null, 2)}\n`);
|
|
219
|
+
console.log(` 报告已写入 ${resolve(args.json)}`);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (args.failOnDead && dead > 0) process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
|
|
226
|
+
main();
|
|
227
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* LQIP 生成脚本(M3b-b9,P1-14):扫描站点 public 下的图片,每张采样
|
|
4
|
+
* 2×2 像素取三色,产出 18 字符 compact hex(三段 rgb hex 拼接),
|
|
5
|
+
* 整体写入站点根 lqips.json(键 → 色,全量重建,增量收益有限故不做)。
|
|
6
|
+
*
|
|
7
|
+
* 运行:pnpm --filter site lqip(cwd 必须是 site 根)
|
|
8
|
+
* 消费链路:lqips.json → themeLqipsPlugin(vite.ts)→ virtual:theme/lqips
|
|
9
|
+
* → utils/lqip.ts getLqipStyle() → 构建期内联渐变(零客户端请求)。
|
|
10
|
+
*
|
|
11
|
+
* 键约定:`public:<posix 相对路径>`。主题图片一律 public 路径或外链
|
|
12
|
+
* (不用 astro:assets),故无需 src: 键;外链/无数据在消费端自然降级纯色。
|
|
13
|
+
* sharp 经本脚本文件位置解析到 theme 包依赖,与 cwd 无关。
|
|
14
|
+
*/
|
|
15
|
+
import fs from "node:fs";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import sharp from "sharp";
|
|
19
|
+
|
|
20
|
+
const cwd = process.cwd();
|
|
21
|
+
const publicDir = path.join(cwd, "public");
|
|
22
|
+
const outFile = path.join(cwd, "lqips.json");
|
|
23
|
+
|
|
24
|
+
const EXTS = new Set([".png", ".jpg", ".jpeg", ".webp", ".avif"]);
|
|
25
|
+
const EXCLUDED_DIRS = new Set(["node_modules", ".astro", "dist", ".git"]);
|
|
26
|
+
|
|
27
|
+
if (!fs.existsSync(publicDir)) {
|
|
28
|
+
console.error(`[lqip] 未找到 ${publicDir},请在 site 根目录运行本脚本`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 递归收集图片相对路径(posix 风格,排除构建/依赖目录) */
|
|
33
|
+
function collectImages(dir, base = "") {
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
36
|
+
if (entry.isDirectory()) {
|
|
37
|
+
if (EXCLUDED_DIRS.has(entry.name)) continue;
|
|
38
|
+
out.push(
|
|
39
|
+
...collectImages(
|
|
40
|
+
path.join(dir, entry.name),
|
|
41
|
+
base ? `${base}/${entry.name}` : entry.name,
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
} else if (EXTS.has(path.extname(entry.name).toLowerCase())) {
|
|
45
|
+
out.push(base ? `${base}/${entry.name}` : entry.name);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** sharp 2×2 fill 采样 → 取 [0][1][3] 三像素(左上/右上/右下)rgb hex 拼接 */
|
|
52
|
+
async function sampleColors(file) {
|
|
53
|
+
const { data, info } = await sharp(file)
|
|
54
|
+
.resize(2, 2, { fit: "fill" })
|
|
55
|
+
.removeAlpha()
|
|
56
|
+
.raw()
|
|
57
|
+
.toBuffer({ resolveWithObject: true });
|
|
58
|
+
const hex = (i) => {
|
|
59
|
+
const o = i * info.channels;
|
|
60
|
+
return [data[o], data[o + 1], data[o + 2]]
|
|
61
|
+
.map((v) => v.toString(16).padStart(2, "0"))
|
|
62
|
+
.join("");
|
|
63
|
+
};
|
|
64
|
+
return hex(0) + hex(1) + hex(3);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const files = collectImages(publicDir);
|
|
69
|
+
const entries = await Promise.all(
|
|
70
|
+
files.map(async (rel) => [
|
|
71
|
+
`public:${rel}`,
|
|
72
|
+
await sampleColors(path.join(publicDir, rel)),
|
|
73
|
+
]),
|
|
74
|
+
);
|
|
75
|
+
fs.writeFileSync(
|
|
76
|
+
outFile,
|
|
77
|
+
JSON.stringify(Object.fromEntries(entries), null, 2) + "\n",
|
|
78
|
+
);
|
|
79
|
+
console.log(`[lqip] ${files.length} 张图片 → ${path.relative(cwd, outFile)}`);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.error("[lqip] 生成失败:", err);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|