From 62a747550088c76d28a1e7ebbfbb29799e9104bd Mon Sep 17 00:00:00 2001 From: Nicola Spadari Date: Thu, 27 Feb 2025 09:57:53 +0100 Subject: [PATCH] Handle empty pages --- app/app.config.ts | 21 +++++++++++++++++---- app/composables/pages.ts | 12 ++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/app.config.ts b/app/app.config.ts index b3880f3..7235117 100644 --- a/app/app.config.ts +++ b/app/app.config.ts @@ -7,10 +7,23 @@ export default defineAppConfig({ nuxtSite: "https://nuxt.com", nuxtUiSite: "https://ui3.nuxt.dev" }, - icons: { - system: "lucide:square-terminal", - storage: "lucide:archive", - interface: "lucide:app-window-mac" + pageCategories: { + system: { + label: "System", + icon: "lucide:square-terminal" + }, + storage: { + label: "Storage", + icon: "lucide:archive" + }, + interface: { + label: "Interface", + icon: "lucide:app-window-mac" + }, + other: { + label: "Other", + icon: "lucide:folder" + } }, ui: { colors: { diff --git a/app/composables/pages.ts b/app/composables/pages.ts index f92862b..5b3b87b 100644 --- a/app/composables/pages.ts +++ b/app/composables/pages.ts @@ -1,26 +1,26 @@ export const usePages = () => { const router = useRouter(); - const { icons } = useAppConfig(); + const { pageCategories } = useAppConfig(); const routes = router.getRoutes().filter((route) => route.name !== "index" && route.name !== "all"); const categorizedRoutes = routes.reduce((acc, route) => { - const category = route.meta.category as string; + const category = route.meta.category as string || "other"; if (!category) return acc; if (!acc[category]) { acc[category] = { - label: category.charAt(0).toUpperCase() + category.slice(1), - icon: icons[category as keyof typeof icons] || "i-lucide-folder", + label: pageCategories[category as keyof typeof pageCategories]?.label, + icon: pageCategories[category as keyof typeof pageCategories]?.icon || "i-lucide-folder", to: route.path, children: [] }; } acc[category].children.push({ - label: route.meta.name as string, + label: route.meta.name as string || route.name, description: route.meta.description as string, - icon: route.meta.icon, + icon: route.meta.icon || "i-lucide-file", to: route.path });