From d1f8da7ad4ed9f1c2ee489295fc802b5fe955c16 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Thu, 19 Dec 2024 14:29:26 -0600 Subject: [PATCH] chore(docs): debug --- .../paste-website/src/pages/sitemap.xml.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index c2889c4065..81c268ca33 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -1,3 +1,5 @@ +import fs from "fs"; +import path from "path"; import { globby } from "globby-esm"; import type { GetServerSideProps } from "next"; @@ -7,9 +9,24 @@ const Sitemap = (): React.ReactElement | null => { export const revalidate = "force-cache"; +function getRoutes() { + const pagesDirectory = path.join(process.cwd(), "pages"); + const fileNames = fs.readdirSync(pagesDirectory); + + const files = fileNames + .filter((fileName) => fileName.endsWith(".js") || fileName.endsWith(".jsx")) + .map((fileName) => { + const route = fileName === "index.js" ? "/" : `/${fileName.replace(/\.js(x)?$/, "")}`; + return route; + }); + + // eslint-disable-next-line no-console + console.log("ai generated", files); +} + export const getServerSideProps: GetServerSideProps = async ({ res }) => { const BASE_URL = "https://paste.twilio.design"; - + getRoutes(); // Get a list of all pages currently in the site, must be mdx and not tsx which they all currently are const uncompiledPaths = await globby(["**/*.mdx"], { cwd: process.cwd() });