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 20, 2024
1 parent b2344a5 commit ac9f21c
Showing 1 changed file with 5 additions and 34 deletions.
39 changes: 5 additions & 34 deletions packages/paste-website/src/pages/sitemap.xml.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { globby } from "globby-esm";
import type { GetServerSideProps } from "next";

import { SITEMAP } from "../../../../cypress/integration/sitemap-vrt/constants"; // Import the SITEMAP used for cypress
Expand All @@ -9,51 +8,23 @@ 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"], { cwd: process.cwd() });

// eslint-disable-next-line no-console
console.log(process.cwd(), __dirname);

const urlPaths = uncompiledPaths.map((individualPath) => {
// Remove `src/pages/`
let modifiedPath = individualPath.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}/${individualPath}`;
});

const paths = await globby(["**/*.mdx", "!sitemap.xml.js", "!404.js", "!_*.js"], {
cwd: process.cwd(),
});

// eslint-disable-next-line no-console
console.log("cached pages:", paths);

// Log the SITEMAP
// eslint-disable-next-line no-console
console.log("SITEMAP_LOCAL:", SITEMAP);

const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
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
.map((url) => {
return `
${SITEMAP.map((url) => {
return `
<url>
<loc>${url}</loc>
<loc>${BASE_URL}${url}</loc>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
`;
})
.join("")}
}).join("")}
</urlset>
`;

Expand Down

0 comments on commit ac9f21c

Please sign in to comment.