From fe566c939c836a72c86ba8c4238821bf46a2ea4c Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Mon, 16 Dec 2024 11:19:02 -0600 Subject: [PATCH 01/22] chore(docs): fix sitemap caching --- packages/paste-website/src/pages/sitemap.xml.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 10033d0b4a..9e888971ac 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -1,16 +1,19 @@ import { globby } from "globby-esm"; import type { GetServerSideProps } from "next"; +import { unstable_noStore as noStore } from "next/cache"; const Sitemap = (): React.ReactElement | null => { return null; }; 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}/`; From 1745ac2a21c10b0a2eb02e51e29f896cacc234bd Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Tue, 17 Dec 2024 11:16:37 -0600 Subject: [PATCH 02/22] 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 ` From 8e13c3529e256c65a9654944611c7c7e1ed98d80 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Tue, 17 Dec 2024 12:15:33 -0600 Subject: [PATCH 03/22] chore(docs): add root to sitemap --- packages/paste-website/src/pages/sitemap.xml.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index efa34f0686..b858aebcdc 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -25,6 +25,11 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { const sitemap = ` + + ${BASE_URL} + daily + 0.7 + ${urlPaths .map((url) => { return ` From eeb430624ff8a9b40bb9ccd96aea1765bf7da566 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 12:48:11 -0600 Subject: [PATCH 04/22] chore(docs): test different sitemap --- packages/paste-website/src/pages/sitemap.xml.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index b858aebcdc..e655e135a2 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -11,7 +11,7 @@ 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(["**/pages/**/*.mdx", "!**/api/**", "!**/pages/404/**"]); + const uncompiledPaths = await globby(["**/pages/**/*.mdx", "!**/api/**", "!**/pages/404/**", "!**/pages/blog/**"]); const urlPaths = uncompiledPaths.map((path) => { // Remove `src/pages/` From 3efd925d367fb0c86de46a443dfee5503162cdae Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 13:08:37 -0600 Subject: [PATCH 05/22] chore(docs): test different sitemap --- packages/paste-website/src/pages/sitemap.xml.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index e655e135a2..ca56cebe21 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -11,7 +11,7 @@ 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(["**/pages/**/*.mdx", "!**/api/**", "!**/pages/404/**", "!**/pages/blog/**"]); + const uncompiledPaths = await globby(["**/*.mdx", "!**/api/**", "!**/404/**"]); const urlPaths = uncompiledPaths.map((path) => { // Remove `src/pages/` From 7d1647c74df472b9a889aade55d0c19ab23643ee Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 13:24:10 -0600 Subject: [PATCH 06/22] chore(docs): attempt moving readme file --- .../blog/README => internal-docs/engineering/doc-site/blogs.md | 0 packages/paste-website/src/pages/sitemap.xml.tsx | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/paste-website/src/pages/blog/README => internal-docs/engineering/doc-site/blogs.md (100%) diff --git a/packages/paste-website/src/pages/blog/README b/internal-docs/engineering/doc-site/blogs.md similarity index 100% rename from packages/paste-website/src/pages/blog/README rename to internal-docs/engineering/doc-site/blogs.md diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index ca56cebe21..2be436bbcc 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -11,7 +11,7 @@ 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", "!**/api/**", "!**/404/**"]); + const uncompiledPaths = await globby(["**/*.mdx", "!**/api/**", "!**/404/**", "!**/blog/001-template*"]); const urlPaths = uncompiledPaths.map((path) => { // Remove `src/pages/` From cb349f904e951f4c8d4030c3b4f44bc5954fd824 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 13:39:45 -0600 Subject: [PATCH 07/22] chore(docs): use cwd --- packages/paste-website/src/pages/sitemap.xml.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 2be436bbcc..cf4b9d32e3 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -11,7 +11,9 @@ 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", "!**/api/**", "!**/404/**", "!**/blog/001-template*"]); + const uncompiledPaths = await globby(["**/pages/**/*.mdx", "!**/api/**", "!**/404/**", "!**/blog/001-template*"], { + cwd: process.cwd(), + }); const urlPaths = uncompiledPaths.map((path) => { // Remove `src/pages/` From ed7ec6df89bb8309dfcf13f0840b841cefe5c335 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 14:04:45 -0600 Subject: [PATCH 08/22] chore(docs): debug --- .../blogs.md => packages/paste-website/src/pages/blog/README | 0 packages/paste-website/src/pages/sitemap.xml.tsx | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename internal-docs/engineering/doc-site/blogs.md => packages/paste-website/src/pages/blog/README (100%) diff --git a/internal-docs/engineering/doc-site/blogs.md b/packages/paste-website/src/pages/blog/README similarity index 100% rename from internal-docs/engineering/doc-site/blogs.md rename to packages/paste-website/src/pages/blog/README diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index cf4b9d32e3..059a141496 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -11,7 +11,7 @@ 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(["**/pages/**/*.mdx", "!**/api/**", "!**/404/**", "!**/blog/001-template*"], { + const uncompiledPaths = await globby(["**/pages/**/*"], { cwd: process.cwd(), }); @@ -22,7 +22,7 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { modifiedPath = modifiedPath.replace(/\.mdx$/, ""); // Remove `/index` if it's at the end of the path modifiedPath = modifiedPath.replace(/\/index$/, ""); - return `${BASE_URL}/${modifiedPath}`; + return `${BASE_URL}/${path}`; }); const sitemap = ` From 24f2da3c0090e9e9bbefebad18f55eb871d87ddb Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 14:29:42 -0600 Subject: [PATCH 09/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 059a141496..3aa7de2654 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -11,9 +11,9 @@ 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(["**/pages/**/*"], { - cwd: process.cwd(), - }); + const uncompiledPaths = await globby(["**/pages/**/*"]); + + console.log(uncompiledPaths); const urlPaths = uncompiledPaths.map((path) => { // Remove `src/pages/` From e1914de22dea05019e8f1a0bdea837f1ff88bdb5 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 15:33:08 -0600 Subject: [PATCH 10/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 3aa7de2654..8f885dab26 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -13,7 +13,10 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { // 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/**/*"]); + // eslint-disable-next-line no-console console.log(uncompiledPaths); + // eslint-disable-next-line no-console + console.log(process.cwd(), __dirname); const urlPaths = uncompiledPaths.map((path) => { // Remove `src/pages/` From acdc43ad7ec4fe95b106431a74994f79e7cc7bd0 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 15:51:20 -0600 Subject: [PATCH 11/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 8f885dab26..9a4d60a9a0 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -11,7 +11,7 @@ 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(["**/pages/**/*"]); + const uncompiledPaths = await globby(["**/*.mdx"]); // eslint-disable-next-line no-console console.log(uncompiledPaths); From 78eae0b802b7af360764da0e5217ae8998c962f0 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 16:13:45 -0600 Subject: [PATCH 12/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 9a4d60a9a0..7b2b01669d 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -7,14 +7,15 @@ const Sitemap = (): React.ReactElement | null => { }; export const getServerSideProps: GetServerSideProps = async ({ res }) => { - noStore(); 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(uncompiledPaths); + console.log(cachedpaths); // eslint-disable-next-line no-console console.log(process.cwd(), __dirname); From 0b27cea42d9ead95badcce8de82e38f938e5725d Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 16:27:36 -0600 Subject: [PATCH 13/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 7b2b01669d..0e42ebe674 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -1,6 +1,5 @@ import { globby } from "globby-esm"; import type { GetServerSideProps } from "next"; -import { unstable_noStore as noStore } from "next/cache"; const Sitemap = (): React.ReactElement | null => { return null; From 26b531de03c47e97524f4e405890043938d9900f Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Wed, 18 Dec 2024 16:48:43 -0600 Subject: [PATCH 14/22] chore(docs): debug --- .../paste-website/src/pages/sitemap.xml.tsx | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) 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 ` From 9e58d87fb361d3b3406c42d1f03c8cedf066a1f6 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Thu, 19 Dec 2024 08:18:22 -0600 Subject: [PATCH 15/22] chore(docs): debug --- .../paste-website/src/pages/sitemap.xml.tsx | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 10033d0b4a..0e8b61de9d 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -5,12 +5,37 @@ const Sitemap = (): React.ReactElement | null => { return null; }; +export const revalidate = "force-cache"; + 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, }); + + console.log("cached pages:", paths); + const staticPaths = paths.map((staticPagePath) => { const path = staticPagePath.replace(".js", ""); const route = path === "index" ? "" : `${path}/`; @@ -20,7 +45,12 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { const sitemap = ` - ${staticPaths + + ${BASE_URL} + daily + 0.7 + + ${urlPaths .map((url) => { return ` From 7a1a3ec8e2a212287ecae8babfa8ae351a809715 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Thu, 19 Dec 2024 08:40:31 -0600 Subject: [PATCH 16/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 0e8b61de9d..0d982351b5 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -34,6 +34,7 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { cwd: __dirname, }); + // eslint-disable-next-line no-console console.log("cached pages:", paths); const staticPaths = paths.map((staticPagePath) => { @@ -43,6 +44,9 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { return `${BASE_URL}/${route}`; }); + // eslint-disable-next-line no-console + console.log("staticPaths pages:", staticPaths); + const sitemap = ` From 3389b325cd866ed4f29acf881876726c7216ec8d Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Thu, 19 Dec 2024 13:14:56 -0600 Subject: [PATCH 17/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 0d982351b5..7605301f36 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -11,12 +11,8 @@ 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 uncompiledPaths = await globby(["**/*.mdx"], { cwd: process.cwd() }); - 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); @@ -31,7 +27,7 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { }); const paths = await globby(["**/*.js", "!sitemap.xml.js", "!404.js", "!_*.js"], { - cwd: __dirname, + cwd: process.cwd(), }); // eslint-disable-next-line no-console From e414dc94ee7fe33cb63f9c15a2edef04a0e31e22 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Thu, 19 Dec 2024 14:12:20 -0600 Subject: [PATCH 18/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 7605301f36..c2889c4065 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -26,7 +26,7 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { return `${BASE_URL}/${path}`; }); - const paths = await globby(["**/*.js", "!sitemap.xml.js", "!404.js", "!_*.js"], { + const paths = await globby(["**/*.mdx", "!sitemap.xml.js", "!404.js", "!_*.js"], { cwd: process.cwd(), }); From d1f8da7ad4ed9f1c2ee489295fc802b5fe955c16 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Thu, 19 Dec 2024 14:29:26 -0600 Subject: [PATCH 19/22] chore(docs): debug --- .../paste-website/src/pages/sitemap.xml.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index c2889c4065..81c268ca33 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -1,3 +1,5 @@ +import fs from "fs"; +import path from "path"; import { globby } from "globby-esm"; import type { GetServerSideProps } from "next"; @@ -7,9 +9,24 @@ const Sitemap = (): React.ReactElement | null => { export const revalidate = "force-cache"; +function getRoutes() { + const pagesDirectory = path.join(process.cwd(), "pages"); + const fileNames = fs.readdirSync(pagesDirectory); + + const files = fileNames + .filter((fileName) => fileName.endsWith(".js") || fileName.endsWith(".jsx")) + .map((fileName) => { + const route = fileName === "index.js" ? "/" : `/${fileName.replace(/\.js(x)?$/, "")}`; + return route; + }); + + // eslint-disable-next-line no-console + console.log("ai generated", files); +} + export const getServerSideProps: GetServerSideProps = async ({ res }) => { const BASE_URL = "https://paste.twilio.design"; - + getRoutes(); // 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() }); From 386abdb5a01a14b07aca35c69168498e49444bd1 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Thu, 19 Dec 2024 14:30:15 -0600 Subject: [PATCH 20/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 81c268ca33..331d562225 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -21,7 +21,7 @@ function getRoutes() { }); // eslint-disable-next-line no-console - console.log("ai generated", files); + console.log("ai generated", fileNames, files); } export const getServerSideProps: GetServerSideProps = async ({ res }) => { From da482c5e57473d3d38a1425e085e9a802bff7a87 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Thu, 19 Dec 2024 14:44:09 -0600 Subject: [PATCH 21/22] chore(docs): debug --- .../paste-website/src/pages/sitemap.xml.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index 331d562225..c2667ca492 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -1,5 +1,6 @@ import fs from "fs"; import path from "path"; + import { globby } from "globby-esm"; import type { GetServerSideProps } from "next"; @@ -9,20 +10,19 @@ const Sitemap = (): React.ReactElement | null => { export const revalidate = "force-cache"; -function getRoutes() { +const getRoutes = (): void => { const pagesDirectory = path.join(process.cwd(), "pages"); const fileNames = fs.readdirSync(pagesDirectory); const files = fileNames .filter((fileName) => fileName.endsWith(".js") || fileName.endsWith(".jsx")) .map((fileName) => { - const route = fileName === "index.js" ? "/" : `/${fileName.replace(/\.js(x)?$/, "")}`; - return route; + return fileName === "index.js" ? "/" : `/${fileName.replace(/\.js(x)?$/, "")}`; }); // eslint-disable-next-line no-console console.log("ai generated", fileNames, files); -} +}; export const getServerSideProps: GetServerSideProps = async ({ res }) => { const BASE_URL = "https://paste.twilio.design"; @@ -33,14 +33,14 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { // eslint-disable-next-line no-console console.log(process.cwd(), __dirname); - const urlPaths = uncompiledPaths.map((path) => { + const urlPaths = uncompiledPaths.map((individualPath) => { // Remove `src/pages/` - let modifiedPath = path.replace(/^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}/${path}`; + return `${BASE_URL}/${individualPath}`; }); const paths = await globby(["**/*.mdx", "!sitemap.xml.js", "!404.js", "!_*.js"], { @@ -51,8 +51,8 @@ export const getServerSideProps: GetServerSideProps = async ({ res }) => { console.log("cached pages:", paths); const staticPaths = paths.map((staticPagePath) => { - const path = staticPagePath.replace(".js", ""); - const route = path === "index" ? "" : `${path}/`; + const otherPath = staticPagePath.replace(".js", ""); + const route = otherPath === "index" ? "" : `${otherPath}/`; return `${BASE_URL}/${route}`; }); From 677d12fc823a0b6ee1ee657295271fc5d9407681 Mon Sep 17 00:00:00 2001 From: Kristian Antrobus Date: Thu, 19 Dec 2024 15:24:46 -0600 Subject: [PATCH 22/22] chore(docs): debug --- packages/paste-website/src/pages/sitemap.xml.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/paste-website/src/pages/sitemap.xml.tsx b/packages/paste-website/src/pages/sitemap.xml.tsx index c2667ca492..35699fefc6 100644 --- a/packages/paste-website/src/pages/sitemap.xml.tsx +++ b/packages/paste-website/src/pages/sitemap.xml.tsx @@ -11,7 +11,7 @@ const Sitemap = (): React.ReactElement | null => { export const revalidate = "force-cache"; const getRoutes = (): void => { - const pagesDirectory = path.join(process.cwd(), "pages"); + const pagesDirectory = path.join(process.cwd(), "src/pages"); const fileNames = fs.readdirSync(pagesDirectory); const files = fileNames