-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathwithLayout.tsx
More file actions
32 lines (26 loc) · 1.09 KB
/
withLayout.tsx
File metadata and controls
32 lines (26 loc) · 1.09 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
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 DownloadArchiveLayout from '#site/layouts/DownloadArchive';
import GlowingBackdropLayout from '#site/layouts/GlowingBackdrop';
import PostLayout from '#site/layouts/Post';
import type { Layouts } from '#site/types';
import type { FC, PropsWithChildren } from 'react';
const layouts = {
about: AboutLayout,
home: GlowingBackdropLayout,
page: DefaultLayout,
'blog-post': PostLayout,
'blog-category': BlogLayout,
download: DownloadLayout,
'download-archive': DownloadArchiveLayout,
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;