Skip to content

Commit 26b531d

Browse files
committed
chore(docs): debug
1 parent 0b27cea commit 26b531d

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

packages/paste-website/src/pages/sitemap.xml.tsx

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,19 @@ const Sitemap = (): React.ReactElement | null => {
88
export const getServerSideProps: GetServerSideProps = async ({ res }) => {
99
const BASE_URL = "https://paste.twilio.design";
1010

11-
// Get a list of all pages currently in the site, must be mdx and not tsx which they all currently are
12-
const uncompiledPaths = await globby(["**/*.mdx"]);
13-
14-
const cachedpaths = await globby(["**/*"], { cwd: __dirname });
15-
16-
// eslint-disable-next-line no-console
17-
console.log(cachedpaths);
18-
// eslint-disable-next-line no-console
19-
console.log(process.cwd(), __dirname);
20-
21-
const urlPaths = uncompiledPaths.map((path) => {
22-
// Remove `src/pages/`
23-
let modifiedPath = path.replace(/^src\/pages\//, "");
24-
// Remove `.mdx`
25-
modifiedPath = modifiedPath.replace(/\.mdx$/, "");
26-
// Remove `/index` if it's at the end of the path
27-
modifiedPath = modifiedPath.replace(/\/index$/, "");
28-
return `${BASE_URL}/${path}`;
11+
const paths = await globby(["**/*.js", "!sitemap.xml.js", "!404.js", "!_*.js"], {
12+
cwd: __dirname,
13+
});
14+
const staticPaths = paths.map((staticPagePath) => {
15+
const path = staticPagePath.replace(".js", "");
16+
const route = path === "index" ? "" : `${path}/`;
17+
18+
return `${BASE_URL}/${route}`;
2919
});
3020

3121
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
3222
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33-
<url>
34-
<loc>${BASE_URL}</loc>
35-
<changefreq>daily</changefreq>
36-
<priority>0.7</priority>
37-
</url>
38-
${urlPaths
23+
${staticPaths
3924
.map((url) => {
4025
return `
4126
<url>

0 commit comments

Comments
 (0)