Stage M7
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user