diff --git a/apps/www/app/glossary/sitemap.ts b/apps/www/app/glossary/sitemap.ts index 3d79ab9f80..6c4e06859c 100644 --- a/apps/www/app/glossary/sitemap.ts +++ b/apps/www/app/glossary/sitemap.ts @@ -1,6 +1,4 @@ -import fs from "node:fs/promises"; -import path from "node:path"; - +import { allGlossaries } from "@/.content-collections/generated"; import { env } from "@/lib/env"; import type { MetadataRoute } from "next"; @@ -8,15 +6,9 @@ export const dynamic = "force-dynamic"; export const revalidate = 0; export default async function sitemap(): Promise { - // NB: I initally tried to import allGlossaries from content-collections but it wasn't available - const glossaryDir = path.join(process.cwd(), "content", "glossary"); - const files = await fs.readdir(glossaryDir); - // NB: Google's limit is 50,000 URLs per sitemap, split up if necessary: https://nextjs.org/docs/app/api-reference/functions/generate-sitemaps - return files - .filter((file) => file.endsWith(".mdx")) - .map((file) => ({ - url: `${env().NEXT_PUBLIC_BASE_URL}/glossary/${path.basename(file, ".mdx")}`, - lastModified: new Date(), // TODO: Get the actual last modified date of the file -- if content-collections doesn't work from marketing-db? - })); + return allGlossaries.map((entry) => ({ + url: `${env().NEXT_PUBLIC_BASE_URL}/glossary/${entry.slug}`, + lastModified: entry.updatedAt, + })); }