import { Skeleton } from "@/components/ui/skeleton"; import React from "react"; import ReactMarkdown from "react-markdown"; import Head from "next/head"; import clientPromise from "@/lib/db"; import { notFound } from "next/navigation"; interface Page { title: string; content: string; } export const dynamic = "force-static"; const Page = async (props: { params: Promise<{ slug: string }> }) => { const params = await props.params; const { slug } = params; let page: Page | null = null; let isNotFound = false; try { const client = await clientPromise; const db = client.db(process.env.MONGODB_DB); const fetchedPage = (await db .collection("pages") .findOne({ slug })) as unknown as Page; if (fetchedPage) { page = fetchedPage; } else { isNotFound = true; } } catch (err) {} if (isNotFound) { notFound(); } if (!page) { return null; } return ( <>

{page.title} change log

{page.content}
); }; export async function generateStaticParams() { try { const client = await clientPromise; const db = client.db(process.env.MONGODB_DB); const slugs = await db.collection("pages").find().toArray(); return slugs.map((element) => { return { slug: element.slug }; }); } catch (err) { return []; } } export default Page;