@windcoder/astro-theme-orchid 0.2.1 → 0.4.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 +5 -3
- package/package.json +4 -2
- package/scripts/check-friends.mjs +227 -0
- package/scripts/generate-lqips.mjs +234 -20
- package/scripts/migrate-posts.mjs +375 -0
- package/src/components/AlbumCard.astro +4 -1
- package/src/components/Analytics.astro +3 -0
- package/src/components/BaseLayout.astro +222 -39
- package/src/components/DisplaySettings.astro +383 -0
- package/src/components/Header.astro +56 -2
- package/src/components/MusicPlayer.astro +45 -5
- package/src/components/MusicWidget.astro +265 -0
- package/src/components/PhotoCard.astro +13 -1
- package/src/components/PostCard.astro +4 -1
- package/src/components/SakuraEffect.astro +126 -28
- package/src/components/Sidebar.astro +28 -7
- package/src/components/analytics/WebVitals.astro +72 -0
- package/src/i18n/en.ts +42 -0
- package/src/i18n/ja.ts +213 -0
- package/src/i18n/ko.ts +212 -0
- package/src/i18n/resolve.ts +10 -1
- package/src/i18n/ru.ts +213 -0
- package/src/i18n/zh-CN.ts +43 -0
- package/src/i18n/zh-TW.ts +208 -0
- package/src/index.ts +23 -0
- package/src/plugins/rehype.ts +76 -4
- package/src/routes/bangumi.astro +110 -0
- package/src/routes/friends.astro +10 -2
- package/src/routes/manifest.webmanifest.ts +33 -0
- package/src/routes/page/[page].astro +3 -0
- package/src/routes/search.astro +24 -0
- package/src/routes/sponsor.astro +17 -4
- package/src/routes/sw.js.ts +127 -0
- package/src/schema.ts +446 -45
- package/src/scripts/app.ts +805 -37
- package/src/styles/global.css +939 -18
- package/src/utils/gallery.ts +3 -1
- package/src/utils/image.ts +79 -0
- package/src/utils/lqip.ts +21 -12
- package/src/utils/thumb.ts +26 -0
- package/src/vite.ts +95 -8
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 文章迁移工具(§4.94):把 Hexo / Hugo 或通用 Markdown 博客文章迁移为符合
|
|
4
|
+
* 主题 definePostSchema 的 frontmatter(title/published 必需,其余尽力映射),
|
|
5
|
+
* 正文一字不动;默认 dry-run 只出报告,--write 才写盘。
|
|
6
|
+
*
|
|
7
|
+
* 用法(站点根目录):
|
|
8
|
+
* node node_modules/@windcoder/astro-theme-orchid/scripts/migrate-posts.mjs \
|
|
9
|
+
* --src <文章目录> [--platform hexo|hugo|generic] [--out migrated-posts] \
|
|
10
|
+
* [--write] [--flat]
|
|
11
|
+
*
|
|
12
|
+
* 规则:
|
|
13
|
+
* - 只迁移 frontmatter。主题无 <!-- more --> 摘要分隔符机制,列表摘要由
|
|
14
|
+
* remark-excerpt 取正文首段自动兜底,无需转换。
|
|
15
|
+
* - 标题三级回退:frontmatter → 正文首个 `# 标题` → 文件名;
|
|
16
|
+
* 发布时间缺失时用文件修改时间兜底。
|
|
17
|
+
* - 白名单之外的 frontmatter 字段不写入目标,仅在报告中列出,便于人工核对。
|
|
18
|
+
* - 正文中的相对路径图片在报告中提示:目录结构调整后需人工核对引用。
|
|
19
|
+
* - 输出文件名取自源文件名(Hugo 优先 slug 字段),冲突自动加 -2/-3 序号;
|
|
20
|
+
* 默认保留相对目录结构,--flat 拍平到输出根目录。
|
|
21
|
+
*/
|
|
22
|
+
import {
|
|
23
|
+
mkdirSync,
|
|
24
|
+
readdirSync,
|
|
25
|
+
readFileSync,
|
|
26
|
+
statSync,
|
|
27
|
+
writeFileSync,
|
|
28
|
+
} from "node:fs";
|
|
29
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
30
|
+
import { pathToFileURL } from "node:url";
|
|
31
|
+
import { parse, stringify } from "yaml";
|
|
32
|
+
|
|
33
|
+
const pad2 = (n) => String(n).padStart(2, "0");
|
|
34
|
+
|
|
35
|
+
function parseArgs(argv) {
|
|
36
|
+
const args = {
|
|
37
|
+
src: "",
|
|
38
|
+
platform: "generic",
|
|
39
|
+
out: "migrated-posts",
|
|
40
|
+
write: false,
|
|
41
|
+
flat: false,
|
|
42
|
+
};
|
|
43
|
+
for (let i = 0; i < argv.length; i++) {
|
|
44
|
+
const a = argv[i];
|
|
45
|
+
if (a === "--src") args.src = argv[++i];
|
|
46
|
+
else if (a === "--platform") args.platform = argv[++i] ?? "";
|
|
47
|
+
else if (a === "--out") args.out = argv[++i];
|
|
48
|
+
else if (a === "--write") args.write = true;
|
|
49
|
+
else if (a === "--flat") args.flat = true;
|
|
50
|
+
else if (a === "--help" || a === "-h") {
|
|
51
|
+
console.log(
|
|
52
|
+
"用法:node migrate-posts.mjs --src <文章目录> [--platform hexo|hugo|generic] [--out migrated-posts] [--write] [--flat]",
|
|
53
|
+
);
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return args;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** 解析 `---` 界定的 frontmatter;无界定符或 YAML 损坏时 broken/空对象兜底 */
|
|
61
|
+
export function parseFrontmatter(raw) {
|
|
62
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(raw);
|
|
63
|
+
if (!m) return { data: {}, body: raw, broken: false };
|
|
64
|
+
let data = {};
|
|
65
|
+
let broken = false;
|
|
66
|
+
try {
|
|
67
|
+
const parsed = parse(m[1]);
|
|
68
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
69
|
+
data = parsed;
|
|
70
|
+
} else if (parsed != null) {
|
|
71
|
+
broken = true;
|
|
72
|
+
}
|
|
73
|
+
} catch {
|
|
74
|
+
broken = true;
|
|
75
|
+
}
|
|
76
|
+
return { data, body: raw.slice(m[0].length), broken };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** 日期值归一化为 YAML 友好字符串;非法返回 null。
|
|
80
|
+
* date-only 原样保留(避免时区漂移),hexo 斜杠格式转 ISO,
|
|
81
|
+
* 带显式时区偏移的 ISO 串直接取墙钟(同理,避免经 Date 本地化漂移),其余 new Date 兜底。 */
|
|
82
|
+
export function normalizeDate(value) {
|
|
83
|
+
if (value instanceof Date) {
|
|
84
|
+
return Number.isNaN(value.getTime()) ? null : formatDate(value);
|
|
85
|
+
}
|
|
86
|
+
if (typeof value !== "string") return null;
|
|
87
|
+
const s = value.trim();
|
|
88
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s;
|
|
89
|
+
const slash =
|
|
90
|
+
/^(\d{4})\/(\d{2})\/(\d{2})(?:\s+(\d{1,2}):(\d{2})(?::(\d{2}))?)?$/.exec(s);
|
|
91
|
+
if (slash) {
|
|
92
|
+
const date = `${slash[1]}-${slash[2]}-${slash[3]}`;
|
|
93
|
+
return slash[4]
|
|
94
|
+
? `${date}T${pad2(slash[4])}:${slash[5]}:${slash[6] ?? "00"}`
|
|
95
|
+
: date;
|
|
96
|
+
}
|
|
97
|
+
const offseted =
|
|
98
|
+
/^(\d{4}-\d{2}-\d{2})[Tt ](\d{2}:\d{2})(?::(\d{2}))?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:?\d{2})$/.exec(
|
|
99
|
+
s,
|
|
100
|
+
);
|
|
101
|
+
if (offseted) return `${offseted[1]}T${offseted[2]}:${offseted[3] ?? "00"}`;
|
|
102
|
+
const d = new Date(s);
|
|
103
|
+
return Number.isNaN(d.getTime()) ? null : formatDate(d);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Date → 本地时分秒格式:零点只写日期,其余带 T 时间(无时区后缀,保墙钟) */
|
|
107
|
+
export function formatDate(d) {
|
|
108
|
+
const date = `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
|
|
109
|
+
const time = `${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`;
|
|
110
|
+
return time === "00:00:00" ? date : `${date}T${time}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** 任意嵌套结构拍平成非空字符串数组(hexo categories 可能是嵌套数组) */
|
|
114
|
+
function flattenStrings(value) {
|
|
115
|
+
if (value == null) return [];
|
|
116
|
+
if (Array.isArray(value)) return value.flatMap(flattenStrings);
|
|
117
|
+
const s = String(value).trim();
|
|
118
|
+
return s ? [s] : [];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** 标题三级回退:frontmatter → 正文首个 `# 标题` → 文件名 */
|
|
122
|
+
export function resolveTitle(data, body, fallback) {
|
|
123
|
+
const t = data.title;
|
|
124
|
+
if (typeof t === "string" && t.trim()) {
|
|
125
|
+
return { title: t.trim(), from: "frontmatter" };
|
|
126
|
+
}
|
|
127
|
+
if (typeof t === "number") return { title: String(t), from: "frontmatter" };
|
|
128
|
+
const m = /^[ \t]*#[ \t]+(.+?)[ \t]*$/m.exec(body);
|
|
129
|
+
if (m) {
|
|
130
|
+
return { title: m[1].replace(/[#*`_]/g, "").trim(), from: "heading" };
|
|
131
|
+
}
|
|
132
|
+
return { title: fallback, from: "filename" };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** 文件名净化:空白转 -,剔除文件系统不安全字符,空值兜底 "post"(保留中文) */
|
|
136
|
+
export function toSlug(name) {
|
|
137
|
+
const slug = name
|
|
138
|
+
.trim()
|
|
139
|
+
.replace(/\s+/g, "-")
|
|
140
|
+
.replace(/[/\\:*?"<>|\p{Cc}]/gu, "")
|
|
141
|
+
.replace(/^[.-]+|[.-]+$/g, "");
|
|
142
|
+
return slug || "post";
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** 正文里的相对路径图片(不含 http(s)://、//、/、data: 开头) */
|
|
146
|
+
export function findRelativeImages(body) {
|
|
147
|
+
const out = [];
|
|
148
|
+
const re = /!\[[^\]]*\]\(([^)\s]+)[^)]*\)|<img[^>]+src=["']([^"']+)["']/g;
|
|
149
|
+
for (const m of body.matchAll(re)) {
|
|
150
|
+
const url = m[1] ?? m[2];
|
|
151
|
+
if (
|
|
152
|
+
!url.startsWith("/") &&
|
|
153
|
+
!url.startsWith("data:") &&
|
|
154
|
+
!url.startsWith("#") &&
|
|
155
|
+
!/^(https?:)?\/\//.test(url)
|
|
156
|
+
) {
|
|
157
|
+
out.push(url);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 按平台把源 frontmatter 映射为目标白名单字段(键序固定)。
|
|
165
|
+
* 白名单外与未消费的源键进 notes,不写入目标。
|
|
166
|
+
*/
|
|
167
|
+
export function mapFrontmatter(data, platform) {
|
|
168
|
+
const notes = [];
|
|
169
|
+
const used = new Set();
|
|
170
|
+
/** 取第一个有值的键;候选键一律记为已消费(不进未映射报告) */
|
|
171
|
+
const take = (...keys) => {
|
|
172
|
+
let hit;
|
|
173
|
+
for (const k of keys) {
|
|
174
|
+
const v = data[k];
|
|
175
|
+
if (hit === undefined && v !== undefined && v !== null && v !== "") {
|
|
176
|
+
hit = v;
|
|
177
|
+
}
|
|
178
|
+
used.add(k);
|
|
179
|
+
}
|
|
180
|
+
return hit;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const fm = {};
|
|
184
|
+
const title = take("title");
|
|
185
|
+
if (title !== undefined) fm.title = String(title);
|
|
186
|
+
|
|
187
|
+
const description = take("description", "summary", "excerpt");
|
|
188
|
+
if (description !== undefined) fm.description = String(description);
|
|
189
|
+
|
|
190
|
+
const rawPublished =
|
|
191
|
+
platform === "generic"
|
|
192
|
+
? take("published", "date", "created")
|
|
193
|
+
: take("date", "publishDate");
|
|
194
|
+
const published = normalizeDate(rawPublished);
|
|
195
|
+
if (published) fm.published = published;
|
|
196
|
+
|
|
197
|
+
const rawUpdated =
|
|
198
|
+
platform === "hugo"
|
|
199
|
+
? take("lastmod", "updated")
|
|
200
|
+
: take("updated", "modified", "lastmod");
|
|
201
|
+
const updated = normalizeDate(rawUpdated);
|
|
202
|
+
if (updated) fm.updated = updated;
|
|
203
|
+
|
|
204
|
+
if (platform === "hexo") {
|
|
205
|
+
const p = take("published");
|
|
206
|
+
if (p === false || p === "false") fm.draft = true;
|
|
207
|
+
} else {
|
|
208
|
+
const d = take("draft");
|
|
209
|
+
if (d === true || d === "true") fm.draft = true;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
let image;
|
|
213
|
+
if (platform === "hexo") {
|
|
214
|
+
image = take("cover", "image") ?? flattenStrings(take("photos"))[0];
|
|
215
|
+
} else if (platform === "hugo") {
|
|
216
|
+
image = take("image", "cover") ?? flattenStrings(take("images"))[0];
|
|
217
|
+
} else {
|
|
218
|
+
image = take("cover", "image", "banner", "thumbnail");
|
|
219
|
+
}
|
|
220
|
+
if (image !== undefined && image !== "") fm.image = String(image);
|
|
221
|
+
|
|
222
|
+
const tags = flattenStrings(take("tags"));
|
|
223
|
+
if (tags.length) fm.tags = tags;
|
|
224
|
+
|
|
225
|
+
const categories = flattenStrings(take("category", "categories"));
|
|
226
|
+
if (categories.length) fm.category = categories[0];
|
|
227
|
+
|
|
228
|
+
// hugo slug 供输出文件名用(见 migrateFile),标记已消费避免误报
|
|
229
|
+
if (platform === "hugo") take("slug");
|
|
230
|
+
|
|
231
|
+
const unmapped = Object.keys(data).filter((k) => !used.has(k));
|
|
232
|
+
if (unmapped.length) {
|
|
233
|
+
notes.push(`未映射字段:${unmapped.join("、")}(未写入目标)`);
|
|
234
|
+
}
|
|
235
|
+
return { fm, notes };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** 递归收集 src 下 .md/.markdown,返回 posix 分隔符的相对路径(排序稳定) */
|
|
239
|
+
export function scanMarkdownFiles(srcDir) {
|
|
240
|
+
const out = [];
|
|
241
|
+
function walk(dir) {
|
|
242
|
+
for (const ent of readdirSync(dir, { withFileTypes: true })) {
|
|
243
|
+
const abs = join(dir, ent.name);
|
|
244
|
+
if (ent.isDirectory()) walk(abs);
|
|
245
|
+
else if (ent.isFile() && /\.(md|markdown)$/i.test(ent.name)) {
|
|
246
|
+
out.push(relative(srcDir, abs).replace(/\\/g, "/"));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
walk(srcDir);
|
|
251
|
+
return out.sort();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** 迁移单篇:映射 frontmatter + 兜底补齐 + 生成输出路径与文件内容 */
|
|
255
|
+
export function migrateFile({ rel, raw, platform, mtimeMs, usedSlugs, flat }) {
|
|
256
|
+
const notes = [];
|
|
257
|
+
const { data, body, broken } = parseFrontmatter(raw);
|
|
258
|
+
if (broken) notes.push("frontmatter 解析失败,已按无元数据处理");
|
|
259
|
+
|
|
260
|
+
const { fm, notes: mapNotes } = mapFrontmatter(data, platform);
|
|
261
|
+
notes.push(...mapNotes);
|
|
262
|
+
|
|
263
|
+
const base = basename(rel).replace(/\.(md|markdown)$/i, "");
|
|
264
|
+
const title = resolveTitle(data, body, base);
|
|
265
|
+
fm.title = title.title;
|
|
266
|
+
if (title.from === "heading") notes.push("标题缺失,已取正文首个一级标题");
|
|
267
|
+
else if (title.from === "filename") notes.push("标题缺失,已使用文件名");
|
|
268
|
+
|
|
269
|
+
if (!fm.published) {
|
|
270
|
+
fm.published = formatDate(new Date(mtimeMs));
|
|
271
|
+
notes.push("发布时间缺失,已用文件修改时间兜底");
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
for (const img of new Set(findRelativeImages(body))) {
|
|
275
|
+
notes.push(`正文含相对路径图片:${img}(目录调整后需人工核对)`);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const slugSource =
|
|
279
|
+
platform === "hugo" && typeof data.slug === "string" && data.slug.trim()
|
|
280
|
+
? data.slug.trim()
|
|
281
|
+
: base;
|
|
282
|
+
const slug = toSlug(slugSource);
|
|
283
|
+
const dir =
|
|
284
|
+
flat || dirname(rel) === "." ? "" : `${dirname(rel).replace(/\\/g, "/")}/`;
|
|
285
|
+
let relOut = `${dir}${slug}.md`;
|
|
286
|
+
for (let n = 2; usedSlugs.has(relOut); n++) relOut = `${dir}${slug}-${n}.md`;
|
|
287
|
+
usedSlugs.add(relOut);
|
|
288
|
+
|
|
289
|
+
const content = `---\n${stringify(fm)}---\n\n${body.replace(/^\r?\n+/, "")}`;
|
|
290
|
+
return { relOut, fm, content, notes };
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** 迁移整目录:write 为 false 时只生成报告不落盘 */
|
|
294
|
+
export function runMigration({
|
|
295
|
+
src,
|
|
296
|
+
out,
|
|
297
|
+
platform,
|
|
298
|
+
write = false,
|
|
299
|
+
flat = false,
|
|
300
|
+
}) {
|
|
301
|
+
const usedSlugs = new Set();
|
|
302
|
+
const results = [];
|
|
303
|
+
for (const rel of scanMarkdownFiles(src)) {
|
|
304
|
+
const abs = join(src, rel);
|
|
305
|
+
const { mtimeMs } = statSync(abs);
|
|
306
|
+
const r = migrateFile({
|
|
307
|
+
rel,
|
|
308
|
+
raw: readFileSync(abs, "utf8"),
|
|
309
|
+
platform,
|
|
310
|
+
mtimeMs,
|
|
311
|
+
usedSlugs,
|
|
312
|
+
flat,
|
|
313
|
+
});
|
|
314
|
+
if (write) {
|
|
315
|
+
const absOut = resolve(out, r.relOut);
|
|
316
|
+
mkdirSync(dirname(absOut), {
|
|
317
|
+
recursive: true,
|
|
318
|
+
});
|
|
319
|
+
writeFileSync(absOut, r.content);
|
|
320
|
+
}
|
|
321
|
+
results.push({ source: rel, output: r.relOut, notes: r.notes });
|
|
322
|
+
}
|
|
323
|
+
return { platform, total: results.length, write, results };
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
async function main() {
|
|
327
|
+
const args = parseArgs(process.argv.slice(2));
|
|
328
|
+
if (!args.src) {
|
|
329
|
+
console.error(
|
|
330
|
+
"[migrate-posts] 缺少 --src <文章目录>。加 --help 查看用法。",
|
|
331
|
+
);
|
|
332
|
+
process.exit(1);
|
|
333
|
+
}
|
|
334
|
+
if (!["hexo", "hugo", "generic"].includes(args.platform)) {
|
|
335
|
+
console.error(
|
|
336
|
+
`[migrate-posts] 未知 --platform ${args.platform},可选 hexo | hugo | generic。`,
|
|
337
|
+
);
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
340
|
+
const src = resolve(args.src);
|
|
341
|
+
try {
|
|
342
|
+
if (!scanMarkdownFiles(src).length) {
|
|
343
|
+
console.log(
|
|
344
|
+
`[migrate-posts] ${src} 下没有 .md / .markdown 文件,无事可做。`,
|
|
345
|
+
);
|
|
346
|
+
process.exit(0);
|
|
347
|
+
}
|
|
348
|
+
} catch {
|
|
349
|
+
console.error(`[migrate-posts] 无法读取目录 ${src},请确认路径。`);
|
|
350
|
+
process.exit(1);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
console.log(
|
|
354
|
+
`[migrate-posts] 平台 ${args.platform},输出 ${resolve(args.out)}${args.write ? "" : "(dry-run 预览,不会写盘)"}\n`,
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
const report = runMigration({ ...args, src });
|
|
358
|
+
for (const f of report.results) {
|
|
359
|
+
console.log(` ${f.source} → ${f.output}`);
|
|
360
|
+
for (const n of f.notes) console.log(` ⚠ ${n}`);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const noted = report.results.filter((f) => f.notes.length).length;
|
|
364
|
+
console.log(
|
|
365
|
+
`\n[migrate-posts] 完成:${report.total} 篇,${noted} 篇有提示${
|
|
366
|
+
args.write
|
|
367
|
+
? `,已写入 ${resolve(args.out)}`
|
|
368
|
+
: "。确认无误后加 --write 落盘"
|
|
369
|
+
}`,
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
|
|
374
|
+
main();
|
|
375
|
+
}
|
|
@@ -5,6 +5,7 @@ import { t } from "../i18n/index.js";
|
|
|
5
5
|
* data-tags(标签数组)与 data-search(名称/描述/地点/标签全文小写)供 gallery-filter 筛选。
|
|
6
6
|
*/
|
|
7
7
|
import { getLqipStyle } from "../utils/lqip.js";
|
|
8
|
+
import { getThumbInfo } from "../utils/thumb.js";
|
|
8
9
|
|
|
9
10
|
interface Props {
|
|
10
11
|
id: string;
|
|
@@ -33,6 +34,8 @@ const {
|
|
|
33
34
|
const searchText = [name, description, location, ...tags]
|
|
34
35
|
.join(" ")
|
|
35
36
|
.toLowerCase();
|
|
37
|
+
/* §4.106:相册封面用缩略图(点击进详情页看原图,卡片本身无灯箱) */
|
|
38
|
+
const thumb = getThumbInfo(cover);
|
|
36
39
|
---
|
|
37
40
|
|
|
38
41
|
<a class="album-card card" href={`/gallery/${id}/`} data-tags={tags.join(',')} data-search={searchText} aria-label={encrypted ? `${name}(${t('encryptedAlbum')})` : name}>
|
|
@@ -41,7 +44,7 @@ const searchText = [name, description, location, ...tags]
|
|
|
41
44
|
<>
|
|
42
45
|
{/* LQIP 占位渐变(b9.5):外链封面查不到数据时降级纯色 */}
|
|
43
46
|
<div class="qy-lqip" style={getLqipStyle(cover)} aria-hidden="true"></div>
|
|
44
|
-
<img src={
|
|
47
|
+
<img src={thumb.src} alt={name} loading="lazy" decoding="async" data-lqip />
|
|
45
48
|
</>
|
|
46
49
|
) : (
|
|
47
50
|
<span class="album-cover-fallback">
|
|
@@ -8,15 +8,18 @@ import GoogleAnalytics from "./analytics/GoogleAnalytics.astro";
|
|
|
8
8
|
import La51Analytics from "./analytics/La51Analytics.astro";
|
|
9
9
|
import MicrosoftClarity from "./analytics/MicrosoftClarity.astro";
|
|
10
10
|
import UmamiAnalytics from "./analytics/UmamiAnalytics.astro";
|
|
11
|
+
import WebVitals from "./analytics/WebVitals.astro";
|
|
11
12
|
|
|
12
13
|
const a = config.analytics;
|
|
13
14
|
const showGA = a.googleAnalyticsId.trim() !== "";
|
|
14
15
|
const showClarity = a.microsoftClarityId.trim() !== "";
|
|
15
16
|
const showUmami = a.umami.websiteId.trim() !== "";
|
|
16
17
|
const show51la = a.la51.id.trim() !== "";
|
|
18
|
+
const showWebVitals = a.webVitals.endpoint.trim() !== "";
|
|
17
19
|
---
|
|
18
20
|
|
|
19
21
|
{showGA && <GoogleAnalytics analyticsId={a.googleAnalyticsId} />}
|
|
20
22
|
{showClarity && <MicrosoftClarity clarityId={a.microsoftClarityId} />}
|
|
21
23
|
{showUmami && <UmamiAnalytics {...a.umami} />}
|
|
22
24
|
{show51la && <La51Analytics analyticsId={a.la51.id} sdkUrl={a.la51.sdkUrl} ck={a.la51.ck} autoTrack={a.la51.autoTrack} hashMode={a.la51.hashMode} screenRecord={a.la51.screenRecord} />}
|
|
25
|
+
{showWebVitals && <WebVitals {...a.webVitals} />}
|