Initial Paprika Next.js implementation
This commit is contained in:
31
app/[page]/page.tsx
Normal file
31
app/[page]/page.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { LegacyPage } from "@/components/LegacyPage";
|
||||
import { legacyPages, type LegacyPageKey } from "@/lib/legacy-pages";
|
||||
|
||||
const routablePages = new Set(Object.keys(legacyPages));
|
||||
const replacedPages = new Set(["home", "start", "ask", "thanks"]);
|
||||
|
||||
export function generateStaticParams() {
|
||||
return Object.keys(legacyPages)
|
||||
.filter((page) => !replacedPages.has(page))
|
||||
.map((page) => ({ page }));
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ page: string }> }) {
|
||||
const { page: pageParam } = await params;
|
||||
if (!routablePages.has(pageParam)) return {};
|
||||
const page = legacyPages[pageParam as LegacyPageKey];
|
||||
return {
|
||||
title: page.title.replace("Paprika - ", "")
|
||||
};
|
||||
}
|
||||
|
||||
export default async function StaticPage({ params }: { params: Promise<{ page: string }> }) {
|
||||
const { page } = await params;
|
||||
|
||||
if (!routablePages.has(page) || replacedPages.has(page)) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return <LegacyPage pageKey={page as LegacyPageKey} />;
|
||||
}
|
||||
Reference in New Issue
Block a user