Skip to content

Commit

Permalink
chore(docs): debug
Browse files Browse the repository at this point in the history
  • Loading branch information
krisantrobus committed Dec 18, 2024
1 parent 0b27cea commit 26b531d
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions packages/paste-website/src/pages/sitemap.xml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>${BASE_URL}</loc>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
${urlPaths
${staticPaths
.map((url) => {
return `
<url>
Expand Down

0 comments on commit 26b531d

Please sign in to comment.