diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 0e42ebe674..10033d0b4a 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -8,34 +8,19 @@ const Sitemap = (): React.ReactElement | null => { export const getServerSideProps: GetServerSideProps = async ({ res }) => { const BASE_URL = "https://paste.twilio.design"; - // 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"]); - - const cachedpaths = await globby(["**/*"], { cwd: __dirname }); - - // eslint-disable-next-line no-console - console.log(cachedpaths); - // eslint-disable-next-line no-console - console.log(process.cwd(), __dirname); - - 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}/${path}`; + 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}`; }); const sitemap = ` - - ${BASE_URL} - daily - 0.7 - - ${urlPaths + ${staticPaths .map((url) => { return `