Skip to content

Commit b88695a

Browse files
committed
move navigation definition to dedicated file at root src
1 parent 9dc1bfd commit b88695a

File tree

4 files changed

+70
-72
lines changed

4 files changed

+70
-72
lines changed

Diff for: src/components/Footer.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Link from 'next/link'
44
import { usePathname } from 'next/navigation'
55

66
import { Button } from '@/components/Button'
7-
import { navigation } from '@/components/Navigation'
7+
import { nav } from '@/navigation'
88

99
function PageLink({
1010
label,
@@ -39,7 +39,7 @@ function PageLink({
3939

4040
function PageNavigation() {
4141
let pathname = usePathname()
42-
let allPages = navigation.flatMap((group) => group.links)
42+
let allPages = nav.flatMap((group) => group.links)
4343
let currentPageIndex = allPages.findIndex((page) => page.href === pathname)
4444

4545
if (currentPageIndex === -1) {

Diff for: src/components/Navigation.tsx

+3-70
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@ import { useIsInsideMobileNavigation } from '@/components/MobileNavigation'
1111
import { useSectionStore } from '@/components/SectionProvider'
1212
import { Tag } from '@/components/Tag'
1313
import { remToPx } from '@/lib/remToPx'
14-
15-
interface NavGroup {
16-
title: string
17-
links: Array<{
18-
title: string
19-
href: string
20-
}>
21-
}
14+
import { nav } from '@/navigation'
15+
import { NavGroup } from '@/types/nav'
2216

2317
function useInitialValue<T>(value: T, condition = true) {
2418
let initialValue = useRef(value).current
@@ -229,75 +223,14 @@ function NavigationGroup({
229223
)
230224
}
231225

232-
export const navigation: Array<NavGroup> = [
233-
{
234-
title: 'Getting started',
235-
links: [
236-
{ title: 'Introduction', href: '/' },
237-
{ title: 'Quickstart', href: '/quickstart' },
238-
],
239-
},
240-
{
241-
title: 'Core concepts',
242-
links: [
243-
{ title: 'Effects', href: '/effects' },
244-
{ title: 'Commands', href: '/commands' },
245-
{ title: 'Events', href: '/events' },
246-
{ title: 'Timers', href: '/timers' },
247-
{ title: 'Channel Rewards', href: '/channel-rewards' },
248-
{ title: 'Preset Effect Lists', href: '/preset-effect-lists' },
249-
{ title: 'Hotkeys', href: '/hotkeys' },
250-
{ title: 'Counters', href: '/counters' },
251-
{ title: 'Variables', href: '/variables' },
252-
{ title: 'Effect Queues', href: '/effect-queues' },
253-
{ title: 'Setups', href: '/setups' },
254-
],
255-
},
256-
{
257-
title: 'Guides',
258-
links: [
259-
{ title: 'Alert Queues', href: '/guides/alert-queues' },
260-
{ title: 'Conditional Effects', href: '/v5/guides/conditional-effects' },
261-
],
262-
},
263-
{
264-
title: 'Troubleshooting',
265-
links: [
266-
{ title: 'FAQ', href: '/v5/faq' },
267-
],
268-
},
269-
{
270-
title: 'Custom scripts',
271-
links: [
272-
{ title: 'Quickstart', href: '/v5/dev/scripts' },
273-
],
274-
},
275-
{
276-
title: 'API reference',
277-
links: [
278-
{ title: 'Contacts', href: '/contacts' },
279-
{ title: 'Conversations', href: '/conversations' },
280-
{ title: 'Messages', href: '/messages' },
281-
{ title: 'Groups', href: '/groups' },
282-
{ title: 'Attachments', href: '/attachments' },
283-
],
284-
},
285-
{
286-
title: 'Contributing',
287-
links: [
288-
{ title: 'Dev Environment Setup', href: '/v5/dev/environment-setup' },
289-
],
290-
},
291-
]
292-
293226
export function Navigation(props: React.ComponentPropsWithoutRef<'nav'>) {
294227
return (
295228
<nav {...props}>
296229
<ul role="list">
297230
<TopLevelNavItem href="/">API</TopLevelNavItem>
298231
<TopLevelNavItem href="#">Documentation</TopLevelNavItem>
299232
<TopLevelNavItem href="#">Support</TopLevelNavItem>
300-
{navigation.map((group, groupIndex) => (
233+
{nav.map((group, groupIndex) => (
301234
<NavigationGroup
302235
key={group.title}
303236
group={group}

Diff for: src/navigation.ts

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { NavGroup } from './types/nav'
2+
3+
export const nav: Array<NavGroup> = [
4+
{
5+
title: 'Getting started',
6+
links: [
7+
{ title: 'Introduction', href: '/' },
8+
{ title: 'Quickstart', href: '/quickstart' },
9+
],
10+
},
11+
{
12+
title: 'Core concepts',
13+
links: [
14+
{ title: 'Effects', href: '/effects' },
15+
{ title: 'Commands', href: '/commands' },
16+
{ title: 'Events', href: '/events' },
17+
{ title: 'Timers', href: '/timers' },
18+
{ title: 'Channel Rewards', href: '/channel-rewards' },
19+
{ title: 'Preset Effect Lists', href: '/preset-effect-lists' },
20+
{ title: 'Hotkeys', href: '/hotkeys' },
21+
{ title: 'Counters', href: '/counters' },
22+
{ title: 'Variables', href: '/variables' },
23+
{ title: 'Effect Queues', href: '/effect-queues' },
24+
{ title: 'Setups', href: '/setups' },
25+
],
26+
},
27+
{
28+
title: 'Guides',
29+
links: [
30+
{ title: 'Alert Queues', href: '/guides/alert-queues' },
31+
{ title: 'Conditional Effects', href: '/v5/guides/conditional-effects' },
32+
],
33+
},
34+
{
35+
title: 'Troubleshooting',
36+
links: [{ title: 'FAQ', href: '/v5/faq' }],
37+
},
38+
{
39+
title: 'Custom scripts',
40+
links: [{ title: 'Quickstart', href: '/v5/dev/scripts' }],
41+
},
42+
{
43+
title: 'API reference',
44+
links: [
45+
{ title: 'Contacts', href: '/contacts' },
46+
{ title: 'Conversations', href: '/conversations' },
47+
{ title: 'Messages', href: '/messages' },
48+
{ title: 'Groups', href: '/groups' },
49+
{ title: 'Attachments', href: '/attachments' },
50+
],
51+
},
52+
{
53+
title: 'Contributing',
54+
links: [
55+
{ title: 'Dev Environment Setup', href: '/v5/dev/environment-setup' },
56+
],
57+
},
58+
]

Diff for: src/types/nav.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface NavGroup {
2+
title: string
3+
links: Array<{
4+
title: string
5+
href: string
6+
}>
7+
}

0 commit comments

Comments
 (0)