Skip to content

Commit dfe67af

Browse files
committed
Partition by section
1 parent 4390e40 commit dfe67af

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/components/learn-aggregator/items.tsx renamed to src/components/learn-aggregator/learn-pages.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ interface LearnPageItem {
77
description: string
88
icon: string
99
section: "getting-started" | "best-practices"
10+
href: string
1011
}
1112

12-
const _items: Record<LearnPagePath, Omit<LearnPageItem, "title"> | null> = {
13+
const _items: Record<
14+
LearnPagePath,
15+
Omit<LearnPageItem, "title" | "href"> | null
16+
> = {
1317
introduction: {
1418
description:
1519
"Get a high-level overview of GraphQL and how it enables flexible, versionless APIs powered by a strong type system.",
@@ -147,6 +151,12 @@ const _items: Record<LearnPagePath, Omit<LearnPageItem, "title"> | null> = {
147151

148152
export const learnPages = _items as Record<LearnPagePath, LearnPageItem | null>
149153

154+
export const pagesBySection: Record<LearnPageItem["section"], LearnPageItem[]> =
155+
{
156+
"getting-started": [],
157+
"best-practices": [],
158+
}
159+
150160
for (const path in learnPages) {
151161
const page = learnPages[path as LearnPagePath]
152162
if (page === null) continue
@@ -161,4 +171,8 @@ for (const path in learnPages) {
161171
} else {
162172
page.title = path.replace(/-/g, " ").replace(/\b\w/g, c => c.toUpperCase())
163173
}
174+
175+
page.href = `/learn/${path}`
176+
177+
pagesBySection[page.section].push(page)
164178
}

src/pages/learn/index.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Button } from '@/app/conf/_design-system/button';
22

33
import { TocHero, TocHeroContents } from '../../components/toc-hero';
44
import { TeaserSection, LearnHeroStripes } from '../../components/learn-aggregator'
5+
import { pagesBySection } from '../../components/learn-aggregator/learn-pages'
56
import { NavbarFixed } from '../../components/navbar/navbar-fixed'
67

78
<NavbarFixed />
@@ -36,6 +37,7 @@ import { NavbarFixed } from '../../components/navbar/navbar-fixed'
3637
</Button>
3738
}
3839
firstIconsEager
40+
items={pagesBySection["getting-started"]}
3941
/>
4042

4143
<TeaserSection
@@ -48,4 +50,5 @@ import { NavbarFixed } from '../../components/navbar/navbar-fixed'
4850
Explore all best practices
4951
</Button>
5052
}
53+
items={pagesBySection["best-practices"]}
5154
/>

0 commit comments

Comments
 (0)