From 6e40e11f333c571507f9d205627160f0a489e991 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 23 Feb 2024 13:35:27 +0100 Subject: [PATCH] refactor: improve nav and design --- app/components/AppHeader.vue | 44 ++++++++++++++---------------- app/components/NavigationTree.vue | 22 --------------- app/components/global/ReadMore.vue | 2 +- app/layouts/docs.vue | 9 ++++-- app/pages/[...slug].vue | 8 ++++-- app/pages/index.vue | 2 +- app/utils/label.ts | 9 ------ app/utils/nav.ts | 36 ++++++++++++++++++++++++ app/utils/title.ts | 9 ++++++ 9 files changed, 79 insertions(+), 62 deletions(-) delete mode 100644 app/components/NavigationTree.vue delete mode 100644 app/utils/label.ts create mode 100644 app/utils/nav.ts create mode 100644 app/utils/title.ts diff --git a/app/components/AppHeader.vue b/app/components/AppHeader.vue index acc98de..c7ca2ae 100644 --- a/app/components/AppHeader.vue +++ b/app/components/AppHeader.vue @@ -7,23 +7,15 @@ const appConfig = useAppConfig() const { metaSymbol } = useShortcuts() -const route = useRoute() - -const navLinks = computed(() => { - // console.log(mapContentNavigation(navigation.value)) - // console.log(JSON.parse(JSON.stringify(navigation.value, null, 2))) - return navigation.value - .map((nav) => { - if (!nav.children?.find((c) => c._path === nav._path)) { - return - } - return { - label: toLabel(nav._path.substring(1)), - to: nav._path, - active: route.path.startsWith(nav._path), - } - }) - .filter(Boolean) +const docsNav = useDocsNav() + +const headerLinks = computed(() => { + return docsNav.links.map((link) => { + return { + ...link, + children: link.children?.filter((child) => !child.children || child.children.some((c) => c.to === child.to)), + } + }) }) @@ -36,26 +28,30 @@ const navLinks = computed(() => { {{ appConfig.site.name }} - - + + diff --git a/app/components/NavigationTree.vue b/app/components/NavigationTree.vue deleted file mode 100644 index a93bf98..0000000 --- a/app/components/NavigationTree.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/app/components/global/ReadMore.vue b/app/components/global/ReadMore.vue index 1f90e2d..13a582b 100644 --- a/app/components/global/ReadMore.vue +++ b/app/components/global/ReadMore.vue @@ -16,7 +16,7 @@ import { splitByCase, upperFirst } from 'scule' const props = defineProps({ to: { type: String, - required: true, + required: false, }, title: { type: String, diff --git a/app/layouts/docs.vue b/app/layouts/docs.vue index 4aa8a0d..1717a12 100644 --- a/app/layouts/docs.vue +++ b/app/layouts/docs.vue @@ -1,11 +1,14 @@ - +