refactor: Migrate documentation content, rebuild UI components, and update core architecture.
This commit is contained in:
35
lib/routes.ts
Normal file
35
lib/routes.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import docuConfig from "@/docu.json"; // Import JSON file
|
||||
|
||||
export type ContextInfo = {
|
||||
icon: string;
|
||||
description: string;
|
||||
title?: string;
|
||||
};
|
||||
|
||||
export type EachRoute = {
|
||||
title: string;
|
||||
href: string;
|
||||
noLink?: boolean;
|
||||
context?: ContextInfo;
|
||||
items?: EachRoute[];
|
||||
};
|
||||
|
||||
export const ROUTES: EachRoute[] = docuConfig.routes;
|
||||
|
||||
type Page = { title: string; href: string };
|
||||
|
||||
function getRecursiveAllLinks(node: EachRoute): Page[] {
|
||||
const ans: Page[] = [];
|
||||
if (!node.noLink) {
|
||||
ans.push({ title: node.title, href: node.href });
|
||||
}
|
||||
node.items?.forEach((subNode) => {
|
||||
const temp = { ...subNode, href: `${node.href}${subNode.href}` };
|
||||
ans.push(...getRecursiveAllLinks(temp));
|
||||
});
|
||||
return ans;
|
||||
}
|
||||
|
||||
export const page_routes: Page[] = ROUTES.map((route) =>
|
||||
getRecursiveAllLinks(route)
|
||||
).flat();
|
||||
Reference in New Issue
Block a user