Files
admin/apps/web/web-runtime/layouts/registry.tsx
T

25 lines
849 B
TypeScript

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} />;
}