Files
docs.addonsejoli.pro/lib/routes-config.ts
2025-02-23 10:43:08 +07:00

29 lines
731 B
TypeScript

import docuConfig from "@/docu.json"; // Import JSON file
export type EachRoute = {
title: string;
href: string;
noLink?: boolean; // Sekarang mendukung boolean
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();