forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwithLayout.tsx
More file actions
34 lines (28 loc) · 1.15 KB
/
withLayout.tsx
File metadata and controls
34 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { FC, PropsWithChildren } from 'react';
import AboutLayout from '#site/layouts/About';
import ArticlePageLayout from '#site/layouts/ArticlePage';
import BlogLayout from '#site/layouts/Blog';
import DefaultLayout from '#site/layouts/Default';
import DownloadLayout from '#site/layouts/Download';
import DownloadSimpleLayout from '#site/layouts/DownloadSimple';
import GlowingBackdropLayout from '#site/layouts/GlowingBackdrop';
import LearnLayout from '#site/layouts/Learn';
import PostLayout from '#site/layouts/Post';
import type { Layouts } from '#site/types';
const layouts = {
about: AboutLayout,
home: GlowingBackdropLayout,
learn: LearnLayout,
page: DefaultLayout,
'blog-post': PostLayout,
'blog-category': BlogLayout,
download: DownloadLayout,
'download-simple': DownloadSimpleLayout,
article: ArticlePageLayout,
} satisfies Record<Layouts, FC>;
type WithLayoutProps<L = Layouts> = PropsWithChildren<{ layout: L }>;
const WithLayout: FC<WithLayoutProps<Layouts>> = ({ layout, children }) => {
const LayoutComponent = layouts[layout] ?? DefaultLayout;
return <LayoutComponent>{children}</LayoutComponent>;
};
export default WithLayout;