Add initial project files
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type { ComponentType } from 'react';
|
||||
import type { PageDocument, PageSearchParams } from '#web-runtime/types';
|
||||
import BlogPageLayout from './components/BlogPageLayout';
|
||||
import EditorialPageLayout from './components/EditorialPageLayout';
|
||||
import StandardPageLayout from './components/StandardPageLayout';
|
||||
|
||||
export interface PageLayoutProps {
|
||||
page: PageDocument;
|
||||
searchParams?: PageSearchParams;
|
||||
}
|
||||
|
||||
type PageLayout = ComponentType<PageLayoutProps>;
|
||||
|
||||
export const PAGE_LAYOUT_REGISTRY: Readonly<Record<string, PageLayout>> = {
|
||||
'landing': StandardPageLayout,
|
||||
'blog': BlogPageLayout,
|
||||
'blog-item': EditorialPageLayout
|
||||
};
|
||||
|
||||
export function RegisteredPageLayout({ page, searchParams }: PageLayoutProps) {
|
||||
const Layout = PAGE_LAYOUT_REGISTRY[page.layout] ?? StandardPageLayout;
|
||||
|
||||
return <Layout page={page} searchParams={searchParams} />;
|
||||
}
|
||||
Reference in New Issue
Block a user