Update next-intl (and other packages), internationalize URLs

This commit is contained in:
Timothy Armes
2023-10-10 19:48:13 +02:00
committed by Owen Rees
parent 44bfe17c8f
commit effb912641
32 changed files with 902 additions and 939 deletions
+21 -20
View File
@@ -1,27 +1,28 @@
import { MetadataRoute } from "next";
import { locales, pathnames } from "@/utils/navigation";
export default function sitemap(): MetadataRoute.Sitemap {
return ["fr", "en"].flatMap((locale) => {
const prefix = `https://echecsfrance.com/${
locale === "fr" ? "" : `${locale}/`
return locales.flatMap((locale) => {
const prefix = `https://echecsfrance.com${
locale === "fr" ? "" : `/${locale}`
}`;
return [
{
url: prefix,
const paths = Object.keys(pathnames) as Array<keyof typeof pathnames>;
return paths.map((pathname) => {
const route = pathnames[pathname];
if (typeof route === "string") {
return {
url: `${prefix}${route}`,
lastModified: new Date(),
};
}
return {
url: `${prefix}${route[locale]}`,
lastModified: new Date(),
},
{
url: `${prefix}tournois`,
lastModified: new Date(),
},
{
url: `${prefix}qui-sommes-nous`,
lastModified: new Date(),
},
{
url: `${prefix}contactez-nous`,
lastModified: new Date(),
},
];
};
});
});
}