From 1745ac2a21c10b0a2eb02e51e29f896cacc234bd Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Tue, 17 Dec 2024 11:16:37 -0600 Subject: [PATCH] chore(docs): cahnge sitemap to use uncompiled paths --- .../paste-website/src/pages/sitemap.xml.tsx | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 9e888971ac..efa34f0686 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -10,20 +10,22 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { noStore(); const BASE_URL = "https://paste.twilio.design"; - const paths = await globby(["**/*.js", "!sitemap.xml.js", "!404.js", "!_*.js"], { - cwd: __dirname, - }); - - const staticPaths = paths.map((staticPagePath) => { - const path = staticPagePath.replace(".js", ""); - const route = path === "index" ? "" : `${path}/`; - - return `${BASE_URL}/${route}`; + // 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(["**/pages/**/*.mdx", "!**/api/**", "!**/pages/404/**"]); + + const urlPaths = uncompiledPaths.map((path) => { + // Remove `src/pages/` + let modifiedPath = path.replace(/^src\/pages\//, ""); + // Remove `.mdx` + modifiedPath = modifiedPath.replace(/\.mdx$/, ""); + // Remove `/index` if it's at the end of the path + modifiedPath = modifiedPath.replace(/\/index$/, ""); + return `${BASE_URL}/${modifiedPath}`; }); const sitemap = ` - ${staticPaths + ${urlPaths .map((url) => { return `