Skip to content

Commit

Permalink
Migrate getPathname in playground
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Sep 17, 2024
1 parent 6a8c958 commit 52aaeeb
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Metadata} from 'next';
import {useTranslations} from 'next-intl';
import {getPathname, routing, Locale} from '@/i18n/routing';
import {getPathname, Locale} from '@/i18n/routing';

type Props = {
params: {
Expand All @@ -10,19 +10,17 @@ type Props = {
};

export async function generateMetadata({params}: Props): Promise<Metadata> {
let canonical = getPathname({
href: {
pathname: '/news/[articleId]',
params: {articleId: params.articleId}
},
locale: params.locale
});

if (params.locale !== routing.defaultLocale) {
canonical = '/' + params.locale + canonical;
}

return {alternates: {canonical}};
return {
alternates: {
canonical: getPathname({
href: {
pathname: '/news/[articleId]',
params: {articleId: params.articleId}
},
locale: params.locale
})
}
};
}

export default function NewsArticle({params}: Props) {
Expand Down

0 comments on commit 52aaeeb

Please sign in to comment.