File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,24 +14,30 @@ import {buildPageMetadata} from 'lib/buildPageMetadata';
1414import { DocsPage } from './DocsPage' ;
1515import { DocsContent } from 'components/Layout/DocsContent' ;
1616
17- interface RenderArgs {
17+ interface SectionPageProps {
1818 /** Segments below `src/content/`, e.g. ['learn', 'state'] or ['warnings', 'foo']. */
1919 segments : string [ ] ;
2020 section : PageSection ;
2121 routeTree : RouteItem ;
2222}
2323
24+ interface SectionContentProps {
25+ /** Segments below `src/content/`, e.g. ['learn', 'state']. */
26+ segments : string [ ] ;
27+ routeTree : RouteItem ;
28+ }
29+
2430async function loadSection ( segments : string [ ] ) {
2531 const data = await readMarkdownPage ( segments ) ;
2632 if ( ! data ) notFound ( ) ;
2733 return { data, pathname : '/' + segments . join ( '/' ) } ;
2834}
2935
30- export async function renderSectionPage ( {
36+ export async function SectionPage ( {
3137 segments,
3238 section,
3339 routeTree,
34- } : RenderArgs ) {
40+ } : SectionPageProps ) {
3541 const { data, pathname} = await loadSection ( segments ) ;
3642 return (
3743 < DocsPage
@@ -43,7 +49,10 @@ export async function renderSectionPage({
4349 ) ;
4450}
4551
46- export async function renderSectionContent ( { segments, routeTree} : RenderArgs ) {
52+ export async function SectionContent ( {
53+ segments,
54+ routeTree,
55+ } : SectionContentProps ) {
4756 const { data, pathname} = await loadSection ( segments ) ;
4857 return < DocsContent data = { data } pathname = { pathname } routeTree = { routeTree } /> ;
4958}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import type {Metadata} from 'next';
99import sidebarBlog from '../../../sidebarBlog.json' ;
1010import type { RouteItem } from 'components/Layout/getRouteMeta' ;
1111import { collectSectionPaths } from 'lib/collectPaths' ;
12- import { renderSectionPage , sectionPageMetadata } from '../../renderSectionPage ' ;
12+ import { SectionPage , sectionPageMetadata } from '../../SectionPage ' ;
1313
1414interface PageProps {
1515 params : Promise < { slug ?: string [ ] } > ;
@@ -31,9 +31,11 @@ export async function generateMetadata({params}: PageProps): Promise<Metadata> {
3131
3232export default async function BlogPage ( { params} : PageProps ) {
3333 const { slug} = await params ;
34- return renderSectionPage ( {
35- section : 'blog' ,
36- segments : [ 'blog' , ...( slug ?? [ ] ) ] ,
37- routeTree : sidebarBlog as RouteItem ,
38- } ) ;
34+ return (
35+ < SectionPage
36+ section = "blog"
37+ segments = { [ 'blog' , ...( slug ?? [ ] ) ] }
38+ routeTree = { sidebarBlog as RouteItem }
39+ />
40+ ) ;
3941}
Original file line number Diff line number Diff line change @@ -9,10 +9,7 @@ import type {Metadata} from 'next';
99import sidebarCommunity from '../../../sidebarCommunity.json' ;
1010import type { RouteItem } from 'components/Layout/getRouteMeta' ;
1111import { collectSectionPaths } from 'lib/collectPaths' ;
12- import {
13- renderSectionContent ,
14- sectionPageMetadata ,
15- } from '../../renderSectionPage' ;
12+ import { SectionContent , sectionPageMetadata } from '../../SectionPage' ;
1613
1714interface PageProps {
1815 params : Promise < { slug ?: string [ ] } > ;
@@ -33,9 +30,10 @@ export async function generateMetadata({params}: PageProps): Promise<Metadata> {
3330
3431export default async function CommunityPage ( { params} : PageProps ) {
3532 const { slug} = await params ;
36- return renderSectionContent ( {
37- section : 'community' ,
38- segments : [ 'community' , ...( slug ?? [ ] ) ] ,
39- routeTree : sidebarCommunity as RouteItem ,
40- } ) ;
33+ return (
34+ < SectionContent
35+ segments = { [ 'community' , ...( slug ?? [ ] ) ] }
36+ routeTree = { sidebarCommunity as RouteItem }
37+ />
38+ ) ;
4139}
Original file line number Diff line number Diff line change @@ -9,10 +9,7 @@ import type {Metadata} from 'next';
99import sidebarLearn from '../../../sidebarLearn.json' ;
1010import type { RouteItem } from 'components/Layout/getRouteMeta' ;
1111import { collectSectionPaths } from 'lib/collectPaths' ;
12- import {
13- renderSectionContent ,
14- sectionPageMetadata ,
15- } from '../../renderSectionPage' ;
12+ import { SectionContent , sectionPageMetadata } from '../../SectionPage' ;
1613
1714interface PageProps {
1815 params : Promise < { slug ?: string [ ] } > ;
@@ -34,9 +31,10 @@ export async function generateMetadata({params}: PageProps): Promise<Metadata> {
3431
3532export default async function LearnPage ( { params} : PageProps ) {
3633 const { slug} = await params ;
37- return renderSectionContent ( {
38- section : 'learn' ,
39- segments : [ 'learn' , ...( slug ?? [ ] ) ] ,
40- routeTree : sidebarLearn as RouteItem ,
41- } ) ;
34+ return (
35+ < SectionContent
36+ segments = { [ 'learn' , ...( slug ?? [ ] ) ] }
37+ routeTree = { sidebarLearn as RouteItem }
38+ />
39+ ) ;
4240}
Original file line number Diff line number Diff line change @@ -9,10 +9,7 @@ import type {Metadata} from 'next';
99import sidebarReference from '../../../sidebarReference.json' ;
1010import type { RouteItem } from 'components/Layout/getRouteMeta' ;
1111import { collectSectionPaths } from 'lib/collectPaths' ;
12- import {
13- renderSectionContent ,
14- sectionPageMetadata ,
15- } from '../../renderSectionPage' ;
12+ import { SectionContent , sectionPageMetadata } from '../../SectionPage' ;
1613
1714interface PageProps {
1815 params : Promise < { slug ?: string [ ] } > ;
@@ -33,9 +30,10 @@ export async function generateMetadata({params}: PageProps): Promise<Metadata> {
3330
3431export default async function ReferencePage ( { params} : PageProps ) {
3532 const { slug} = await params ;
36- return renderSectionContent ( {
37- section : 'reference' ,
38- segments : [ 'reference' , ...( slug ?? [ ] ) ] ,
39- routeTree : sidebarReference as RouteItem ,
40- } ) ;
33+ return (
34+ < SectionContent
35+ segments = { [ 'reference' , ...( slug ?? [ ] ) ] }
36+ routeTree = { sidebarReference as RouteItem }
37+ />
38+ ) ;
4139}
Original file line number Diff line number Diff line change 88import type { Metadata } from 'next' ;
99import sidebarHome from '../../sidebarHome.json' ;
1010import type { RouteItem } from 'components/Layout/getRouteMeta' ;
11- import { renderSectionPage , sectionPageMetadata } from '../renderSectionPage ' ;
11+ import { SectionPage , sectionPageMetadata } from '../SectionPage ' ;
1212
1313export async function generateMetadata ( ) : Promise < Metadata > {
1414 return sectionPageMetadata ( { section : 'unknown' , segments : [ 'versions' ] } ) ;
1515}
1616
1717export default async function VersionsPage ( ) {
18- return renderSectionPage ( {
19- section : 'unknown' ,
20- segments : [ 'versions' ] ,
21- routeTree : sidebarHome as RouteItem ,
22- } ) ;
18+ return (
19+ < SectionPage
20+ section = "unknown"
21+ segments = { [ 'versions' ] }
22+ routeTree = { sidebarHome as RouteItem }
23+ />
24+ ) ;
2325}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import type {Metadata} from 'next';
99import sidebarHome from '../../../sidebarHome.json' ;
1010import type { RouteItem } from 'components/Layout/getRouteMeta' ;
1111import { collectFlatSectionSlugs } from 'lib/collectPaths' ;
12- import { renderSectionPage , sectionPageMetadata } from '../../renderSectionPage ' ;
12+ import { SectionPage , sectionPageMetadata } from '../../SectionPage ' ;
1313
1414interface PageProps {
1515 params : Promise < { slug : string } > ;
@@ -30,9 +30,11 @@ export async function generateMetadata({params}: PageProps): Promise<Metadata> {
3030
3131export default async function WarningPage ( { params} : PageProps ) {
3232 const { slug} = await params ;
33- return renderSectionPage ( {
34- section : 'unknown' ,
35- segments : [ 'warnings' , slug ] ,
36- routeTree : sidebarHome as RouteItem ,
37- } ) ;
33+ return (
34+ < SectionPage
35+ section = "unknown"
36+ segments = { [ 'warnings' , slug ] }
37+ routeTree = { sidebarHome as RouteItem }
38+ />
39+ ) ;
3840}
You can’t perform that action at this time.
0 commit comments