Files
myeasycms-v2/apps/web/app/[locale]/docs/[...slug]/page.tsx
Giancarlo Buomprisco 7ebff31475 Next.js Supabase V3 (#463)
Version 3 of the kit:
- Radix UI replaced with Base UI (using the Shadcn UI patterns)
- next-intl replaces react-i18next
- enhanceAction deprecated; usage moved to next-safe-action
- main layout now wrapped with [locale] path segment
- Teams only mode
- Layout updates
- Zod v4
- Next.js 16.2
- Typescript 6
- All other dependencies updated
- Removed deprecated Edge CSRF
- Dynamic Github Action runner
2026-03-24 13:40:38 +08:00

81 lines
2.0 KiB
TypeScript

import { cache } from 'react';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { ContentRenderer, createCmsClient } from '@kit/cms';
import { cn } from '@kit/ui/utils';
const getPageBySlug = cache(pageLoader);
interface DocumentationPageProps {
params: Promise<{ slug: string[] }>;
}
async function pageLoader(slug: string) {
const client = await createCmsClient();
return client.getContentItemBySlug({ slug, collection: 'documentation' });
}
export async function generateMetadata({
params,
}: DocumentationPageProps): Promise<Metadata> {
const slug = (await params).slug.join('/');
const page = await getPageBySlug(slug);
if (!page) {
notFound();
}
const { title, description } = page;
return {
title,
description,
};
}
async function DocumentationPage({ params }: DocumentationPageProps) {
const slug = (await params).slug.join('/');
const page = await getPageBySlug(slug);
if (!page) {
notFound();
}
const description = page?.description ?? '';
return (
<div className={'container flex flex-1 flex-col gap-y-4'}>
<div className={'flex flex-1'}>
<div className="relative mx-auto max-w-3xl flex-1 flex-col overflow-x-hidden">
<article
className={cn('mx-auto h-full w-full flex-1 gap-y-12 pt-4 pb-36')}
>
<section className={'mt-4 flex flex-col gap-y-1 pb-4'}>
<h1
className={
'text-foreground text-3xl font-semibold tracking-tighter'
}
>
{page.title}
</h1>
<h2 className={'text-secondary-foreground/80 text-lg'}>
{description}
</h2>
</section>
<div className={'markdoc'}>
<ContentRenderer content={page.content} />
</div>
</article>
</div>
</div>
</div>
);
}
export default DocumentationPage;