Skip to content

Commit

Permalink
move navigation definition to dedicated file at root src
Browse files Browse the repository at this point in the history
  • Loading branch information
ebiggz committed Sep 10, 2024
1 parent 9dc1bfd commit b88695a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 72 deletions.
4 changes: 2 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
73 changes: 3 additions & 70 deletions src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(value: T, condition = true) {
let initialValue = useRef(value).current
Expand Down Expand Up @@ -229,75 +223,14 @@ function NavigationGroup({
)
}

export const navigation: Array<NavGroup> = [
{
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 (
<nav {...props}>
<ul role="list">
<TopLevelNavItem href="/">API</TopLevelNavItem>
<TopLevelNavItem href="#">Documentation</TopLevelNavItem>
<TopLevelNavItem href="#">Support</TopLevelNavItem>
{navigation.map((group, groupIndex) => (
{nav.map((group, groupIndex) => (
<NavigationGroup
key={group.title}
group={group}
Expand Down
58 changes: 58 additions & 0 deletions src/navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { NavGroup } from './types/nav'

export const nav: Array<NavGroup> = [
{
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' },
],
},
]
7 changes: 7 additions & 0 deletions src/types/nav.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface NavGroup {
title: string
links: Array<{
title: string
href: string
}>
}

0 comments on commit b88695a

Please sign in to comment.