From f7f9c7d117067e65e09836e51b8bdf694d00872a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=A9o=20M=C3=A9vollon?= Date: Fri, 7 Jun 2024 18:59:34 +0200 Subject: [PATCH] [warning] page not working anymore --- next-app/app/sitemap.ts | 94 ----------------------------------------- 1 file changed, 94 deletions(-) delete mode 100644 next-app/app/sitemap.ts diff --git a/next-app/app/sitemap.ts b/next-app/app/sitemap.ts deleted file mode 100644 index c681eb7..0000000 --- a/next-app/app/sitemap.ts +++ /dev/null @@ -1,94 +0,0 @@ -import fs from "fs" -import matter from "gray-matter" -import path from "path" -import { stats } from "fs-extra" -import { format, parse } from "date-fns" -import { fr } from "date-fns/locale" -import type { MetadataRoute } from "next" -import { ROOT_URL } from "~/constants" - -export default async function sitemap(): Promise { - const files = fs.readdirSync(path.join(process.cwd(), "content")) - - const posts = await Promise.all( - files - .filter((fn) => fn.endsWith(".mdx")) - .map(async (filename) => { - const filePath = path.join(process.cwd(), "content", filename) - const rawContent = fs.readFileSync(filePath, "utf8") - const { data } = matter(rawContent) - const parsedDate = data.date - ? parse(data.date, "MMMM d, yyyy", new Date(), { locale: fr }) - : null - const currentDate = new Date() - - if (parsedDate >= currentDate) { - return null - } - return { - slug: filename.replace(".mdx", ""), - lastmod: parsedDate - ? format(parsedDate, "yyyy-MM-dd") - : stats.mtime.toISOString(), - } - }) - ) - - return [ - { - url: ROOT_URL, - lastModified: "2023-12-16T19:39:33+00:00", - priority: 1.0, - }, - { - url: `${ROOT_URL}/download`, - lastModified: "2023-12-16T19:39:33+00:00", - priority: 0.8, - }, - { - url: `${ROOT_URL}/blog`, - lastModified: "2023-12-16T19:39:35+00:00", - priority: 0.8, - }, - { - url: `${ROOT_URL}/files/Affiche_OZ-Ensemble.pdf`, - lastModified: "2023-12-16T19:39:33+00:00", - priority: 0.8, - }, - { - url: `${ROOT_URL}/files/AFFICHE_OZ_-_Defi_de_Janvier.pdf`, - lastModified: "2023-12-16T19:39:33+00:00", - priority: 0.8, - }, - { - url: `${ROOT_URL}/files/DEPLIANT-OZ.pdf`, - lastModified: "2023-12-16T19:39:33+00:00", - priority: 0.8, - }, - { - url: `${ROOT_URL}/files/Dossier_de_presse_-_2023_-_Defi_de_Janvier.pdf`, - lastModified: "2023-12-16T19:39:33+00:00", - priority: 0.8, - }, - { - url: `${ROOT_URL}/files/26022024-Oz_Ensemble-Mentions_legales_site_V4.pdf`, - lastModified: "2023-12-16T19:39:33+00:00", - priority: 0.8, - }, - { - url: `${ROOT_URL}/files/25012023-Oz_Ensemble-Politique_de_confidentialite_site_V3.pdf`, - lastModified: "2023-12-16T19:39:33+00:00", - priority: 0.8, - }, - { - url: `${ROOT_URL}/stats`, - lastModified: "2023-12-16T19:39:33+00:00", - priority: 0.8, - }, - ...posts.map(({ slug, lastmod }) => ({ - url: `${ROOT_URL}/blog/${slug}`, - lastModified: lastmod, - priority: 0.8, - })), - ] -}