Files
echecsfrance/src/app/sitemap.ts
T
2024-10-21 15:19:28 +02:00

31 lines
803 B
TypeScript

import { MetadataRoute } from "next";
import { Pathnames, routing } from "@/utils/routing";
export default function sitemap(): MetadataRoute.Sitemap {
return routing.locales.flatMap((locale) => {
const prefix = `https://echecsfrance.com${
locale === "fr" ? "" : `/${locale}`
}`;
const paths = Object.keys(routing.pathnames) as Array<Pathnames>;
return paths
.filter((pathname) => !pathname.includes("["))
.map((pathname) => {
const route = routing.pathnames[pathname];
if (typeof route === "string") {
return {
url: `${prefix}${route}`,
lastModified: new Date(),
};
}
return {
url: `${prefix}${route[locale]}`,
lastModified: new Date(),
};
});
});
}