Skip to content

Commit 94255ee

Browse files
committed
fix: homepage appendix links for directory build format
Point file-cards at slug/index.html and extend check-built-html to reject flat .html appendix hrefs on the built homepage.
1 parent 61396a5 commit 94255ee

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

scripts/check-built-html.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const RAW_K_TAG = /<\/?k>/;
1414
const IMG_REF = /(?:\.\/)?img\/(k|m3)\/([0-9a-f]+)\.png/g;
1515

1616
const failures: string[] = [];
17+
const APPENDIX_SLUGS = ["preface1", "phsource", "ph-comp", "mytaiin8", "dic-cont"] as const;
1718

1819
const pages = listBuiltDictionaryPages(dist);
1920
const volumePages = pages.filter((p) => VOLUME_IDS.includes(p.vol));
@@ -51,6 +52,21 @@ if (volumePages.length === 0) {
5152
failures.push(...verifyBuiltHtmlAnchors(dist, siteBase));
5253
}
5354

55+
const homePath = join(dist, "index.html");
56+
if (existsSync(homePath)) {
57+
const home = readFileSync(homePath, "utf8");
58+
for (const slug of APPENDIX_SLUGS) {
59+
const flat = `${slug}.html`;
60+
const dir = `${slug}/index.html`;
61+
if (home.includes(`href="${siteBase}${flat}"`) || home.includes(`href="/${flat}"`)) {
62+
failures.push(`dist/index.html still links appendix as ${flat} (expected ${dir})`);
63+
}
64+
if (!existsSync(join(dist, slug, "index.html"))) {
65+
failures.push(`dist/${slug}/index.html missing (appendix page)`);
66+
}
67+
}
68+
}
69+
5470
if (failures.length > 0) {
5571
throw new Error(failures.join("\n"));
5672
}

src/pages/index.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@ const baseUrl = import.meta.env.BASE_URL.endsWith("/")
1616
const href = (path = "") => `${baseUrl}${path}`;
1717
const appendix = [
1818
{
19-
href: "preface1.html",
19+
href: "preface1/index.html",
2020
file: "PREFACE1.DIC",
2121
zh: "編輯緣起・凡例",
2222
desc: "吳守禮自述編纂始末(代序),附全書凡例。",
2323
},
2424
{
25-
href: "phsource.html",
25+
href: "phsource/index.html",
2626
file: "PHSOURCE",
2727
zh: "華語台語注音符號溯源",
2828
desc: "注音符號與臺灣方音符號的來歷考述。",
2929
},
3030
{
31-
href: "ph-comp.html",
31+
href: "ph-comp/index.html",
3232
file: "PH-COMP.TXT",
3333
zh: "方音音標對照表",
3434
desc: "漢注、華臺、TLPA、國際音標、甘典、漢閩諸系統對照。",
3535
},
3636
{
37-
href: "mytaiin8.html",
37+
href: "mytaiin8/index.html",
3838
file: "MYTAIIN8",
3939
zh: "綜合閩方言拼音總表",
4040
desc: "閩方言拼音系統總表。",
4141
},
4242
{
43-
href: "dic-cont.html",
43+
href: "dic-cont/index.html",
4444
file: "DIC-CONT.TXT",
4545
zh: "辭典內容說明",
4646
desc: "原始檔案內容一覽。",

0 commit comments

Comments
 (0)