From b88695a267657d3e9a31ff8d294c0307982c7f00 Mon Sep 17 00:00:00 2001 From: ebiggz Date: Tue, 10 Sep 2024 01:13:00 -0500 Subject: [PATCH] move navigation definition to dedicated file at root src --- src/components/Footer.tsx | 4 +- src/components/Navigation.tsx | 73 ++--------------------------------- src/navigation.ts | 58 ++++++++++++++++++++++++++++ src/types/nav.ts | 7 ++++ 4 files changed, 70 insertions(+), 72 deletions(-) create mode 100644 src/navigation.ts create mode 100644 src/types/nav.ts diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index ad8b158..21c9f9c 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -4,7 +4,7 @@ import Link from 'next/link' import { usePathname } from 'next/navigation' import { Button } from '@/components/Button' -import { navigation } from '@/components/Navigation' +import { nav } from '@/navigation' function PageLink({ label, @@ -39,7 +39,7 @@ function PageLink({ function PageNavigation() { let pathname = usePathname() - let allPages = navigation.flatMap((group) => group.links) + let allPages = nav.flatMap((group) => group.links) let currentPageIndex = allPages.findIndex((page) => page.href === pathname) if (currentPageIndex === -1) { diff --git a/src/components/Navigation.tsx b/src/components/Navigation.tsx index 1722e21..f14118e 100644 --- a/src/components/Navigation.tsx +++ b/src/components/Navigation.tsx @@ -11,14 +11,8 @@ import { useIsInsideMobileNavigation } from '@/components/MobileNavigation' import { useSectionStore } from '@/components/SectionProvider' import { Tag } from '@/components/Tag' import { remToPx } from '@/lib/remToPx' - -interface NavGroup { - title: string - links: Array<{ - title: string - href: string - }> -} +import { nav } from '@/navigation' +import { NavGroup } from '@/types/nav' function useInitialValue(value: T, condition = true) { let initialValue = useRef(value).current @@ -229,67 +223,6 @@ function NavigationGroup({ ) } -export const navigation: Array = [ - { - title: 'Getting started', - links: [ - { title: 'Introduction', href: '/' }, - { title: 'Quickstart', href: '/quickstart' }, - ], - }, - { - title: 'Core concepts', - links: [ - { title: 'Effects', href: '/effects' }, - { title: 'Commands', href: '/commands' }, - { title: 'Events', href: '/events' }, - { title: 'Timers', href: '/timers' }, - { title: 'Channel Rewards', href: '/channel-rewards' }, - { title: 'Preset Effect Lists', href: '/preset-effect-lists' }, - { title: 'Hotkeys', href: '/hotkeys' }, - { title: 'Counters', href: '/counters' }, - { title: 'Variables', href: '/variables' }, - { title: 'Effect Queues', href: '/effect-queues' }, - { title: 'Setups', href: '/setups' }, - ], - }, - { - title: 'Guides', - links: [ - { title: 'Alert Queues', href: '/guides/alert-queues' }, - { title: 'Conditional Effects', href: '/v5/guides/conditional-effects' }, - ], - }, - { - title: 'Troubleshooting', - links: [ - { title: 'FAQ', href: '/v5/faq' }, - ], - }, - { - title: 'Custom scripts', - links: [ - { title: 'Quickstart', href: '/v5/dev/scripts' }, - ], - }, - { - title: 'API reference', - links: [ - { title: 'Contacts', href: '/contacts' }, - { title: 'Conversations', href: '/conversations' }, - { title: 'Messages', href: '/messages' }, - { title: 'Groups', href: '/groups' }, - { title: 'Attachments', href: '/attachments' }, - ], - }, - { - title: 'Contributing', - links: [ - { title: 'Dev Environment Setup', href: '/v5/dev/environment-setup' }, - ], - }, -] - export function Navigation(props: React.ComponentPropsWithoutRef<'nav'>) { return (