Refine documentation UI with distinct collection navigation and borderless surfaces
Verify and deploy Tabularium / verify-and-deploy (pull_request) Has been cancelled

This commit is contained in:
2026-10-28 15:31:25 +08:00
parent e381deb04e
commit 627c0ee887
9 changed files with 288 additions and 96 deletions
+24
View File
@@ -0,0 +1,24 @@
import type { DocLink } from "@/lib/docs";
export function collectionLabel(name: string) {
return name.replace(/ 文档$| 源码教程$|问题集$/g, "");
}
export function collectionTone(name?: string) {
if (name?.includes("Pretext")) return "blue";
if (name?.includes("语言设计")) return "violet";
if (name?.includes("垃圾回收")) return "amber";
return "green";
}
export function collectionIcon(name?: string): "book" | "code" | "layers" | "nodes" {
if (name?.includes("Pretext")) return "code";
if (name?.includes("语言设计")) return "layers";
if (name?.includes("垃圾回收")) return "nodes";
return "book";
}
export function collectionEntries(docs: DocLink[]) {
return [...new Set(docs.map((doc) => doc.collection))].map((name) => {
const items = docs.filter((doc) => doc.collection === name);
const entry = items.find((doc) => doc.slug.endsWith("/00-overview")) ?? items[0];
return { name, entry, count: items.length };
});
}