This commit is contained in:
Nông Đức Huy
2026-08-13 23:20:23 +07:00
parent 1e356a2578
commit d9f159a8c3
84 changed files with 7992 additions and 180 deletions
@@ -0,0 +1,37 @@
import type { Metadata } from 'next';
import Link from 'next/link';
import { getTranslations } from 'next-intl/server';
import type { ContentType } from '@sport/types';
import { ContentEditor } from '@/features/cms/content-editor';
type PageProps = {
params: Promise<{ id: string }>;
searchParams: Promise<{ type?: string }>;
};
export async function generateMetadata(): Promise<Metadata> {
const t = await getTranslations('pages.cms');
return { title: t('title') };
}
export default async function Page({ params, searchParams }: PageProps) {
const { id } = await params;
const { type } = await searchParams;
const t = await getTranslations('cms');
// `?type=` only seeds a new entry; an existing one carries its own type, and
// trusting the query string there would let a URL flip a page into a post.
const initialType: ContentType = type === 'PAGE' ? 'PAGE' : 'POST';
return (
<div className="max-w-4xl space-y-6 p-8">
<Link href="/cms" className="text-ink-500 hover:text-ink-950 text-xs">
← {t('backToList')}
</Link>
<ContentEditor entryId={id} initialType={initialType} />
</div>
);
}
+10 -8
View File
@@ -1,22 +1,24 @@
import type { Metadata } from 'next';
import { getTranslations } from 'next-intl/server';
import { PageScaffold } from '@/components/layout/page-scaffold';
import { ContentTable } from '@/features/cms/content-table';
export async function generateMetadata(): Promise<Metadata> {
const t = await getTranslations('pages.cms');
return { title: t('title') };
}
export default async function CmsPage() {
export default async function Page() {
const t = await getTranslations('pages.cms');
return (
<PageScaffold
title={t('title')}
description={t('body')}
permission="cms.read"
milestone="M7 — content"
/>
<div className="space-y-6 p-8">
<header>
<h1 className="text-2xl font-bold">{t('title')}</h1>
<p className="text-ink-500 mt-2 max-w-2xl text-sm">{t('body')}</p>
</header>
<ContentTable />
</div>
);
}