diff --git a/landing/app/mira/wiki/[pageName]/page.tsx b/landing/app/mira/wiki/[pageName]/page.tsx index b5e8e7a..6df40fa 100644 --- a/landing/app/mira/wiki/[pageName]/page.tsx +++ b/landing/app/mira/wiki/[pageName]/page.tsx @@ -141,8 +141,12 @@ export default function WikiPagePage({ return Array.from(groups.entries()).map(([facet, paragraphs]) => ({ facet, paragraphs })); }, [paragraphs, triplets]); - const entity = block?.content?.trim() || decodedName.replace(/^wiki-/, ''); const isWikiPage = block?.type === 'wiki-page'; + // 標題:wiki-page 用 content(entity 名稱),其他(index-entry/schema/log/...)用 page_name 剝 prefix + // 修 bug:原本一律用 block.content,但 index-entry 的 content 是整篇 markdown,會把整個 content render 成 h1 + const entity = isWikiPage + ? (block?.content?.trim() || decodedName.replace(/^wiki-/, '')) + : decodedName.replace(/^(wiki|index)-/, ''); function toggleCollapse(key: string) { setCollapsed((c) => ({ ...c, [key]: !c[key] })); diff --git a/landing/app/mira/wiki/page.tsx b/landing/app/mira/wiki/page.tsx index 7b96d7e..3e9d586 100644 --- a/landing/app/mira/wiki/page.tsx +++ b/landing/app/mira/wiki/page.tsx @@ -6,7 +6,7 @@ // 階段 7-A 已建:mira-wiki-schema、mira-wiki-index(+4 children)、mira-wiki-log(+1 child) // 此頁列出這些 infra block 與既有 wiki-page,方便 leo 在瀏覽器確認 schema 寫得對不對 -import { useEffect, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import Link from 'next/link'; import '../mira.css'; @@ -124,6 +124,27 @@ export default function WikiIndexPage() { }; }, []); + // Dedupe wiki-pages by entity(content)— 累積式設計每個 raw 各建一個 wiki-page, + // 同 entity 多版只在 listing 顯示最新一張卡 + 版本數提示 + const dedupedWikiPages = useMemo(() => { + const groups = new Map(); + for (const p of otherWikiPages) { + const entity = (p.content || '').trim() || p.page_name || '?'; + const existing = groups.get(entity); + if (!existing) { + groups.set(entity, { entity, latest: p, versionCount: 1 }); + } else { + existing.versionCount++; + if ((p.created_at ?? 0) > (existing.latest.created_at ?? 0)) { + existing.latest = p; + } + } + } + return Array.from(groups.values()).sort( + (a, b) => (b.latest.created_at ?? 0) - (a.latest.created_at ?? 0), + ); + }, [otherWikiPages]); + return (
@@ -220,18 +241,18 @@ export default function WikiIndexPage() { )} -
- {otherWikiPages.length > 0 ? ( +
+ {dedupedWikiPages.length > 0 ? (
- {otherWikiPages.map((p) => ( + {dedupedWikiPages.map((g) => ( 1 + ? `${g.versionCount} 版累積 ・ 最新 ${new Date((g.latest.created_at ?? 0) * 1000).toLocaleString('zh-TW')}` + : `建立 ${new Date((g.latest.created_at ?? 0) * 1000).toLocaleString('zh-TW')}` } /> ))}