Refine documentation UI with distinct collection navigation and borderless surfaces
Verify and deploy Tabularium / verify-and-deploy (pull_request) Has been cancelled
Verify and deploy Tabularium / verify-and-deploy (pull_request) Has been cancelled
This commit is contained in:
@@ -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 };
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user