-
-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathpage.tsx
34 lines (30 loc) · 788 Bytes
/
page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {Metadata} from 'next';
import {useTranslations} from 'next-intl';
import {getLocale} from 'next-intl/server';
import {use} from 'react';
import {getPathname} from '@/i18n/navigation';
type Props = {
params: Promise<{
articleId: string;
}>;
};
export async function generateMetadata({params}: Props): Promise<Metadata> {
const {articleId} = await params;
const locale = await getLocale();
return {
alternates: {
canonical: getPathname({
href: {
pathname: '/news/[articleId]',
params: {articleId}
},
locale
})
}
};
}
export default function NewsArticle({params}: Props) {
const {articleId} = use(params);
const t = useTranslations('NewsArticle');
return <h1>{t('title', {articleId})}</h1>;
}