Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): fix sitemap #4200

Merged
merged 29 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fe566c9
chore(docs): fix sitemap caching
krisantrobus Dec 16, 2024
1745ac2
chore(docs): cahnge sitemap to use uncompiled paths
krisantrobus Dec 17, 2024
8e13c35
chore(docs): add root to sitemap
krisantrobus Dec 17, 2024
eeb4306
chore(docs): test different sitemap
krisantrobus Dec 18, 2024
3efd925
chore(docs): test different sitemap
krisantrobus Dec 18, 2024
26ba53e
Merge branch 'main' of github.com:twilio-labs/paste into fix-sitemap
krisantrobus Dec 18, 2024
7d1647c
chore(docs): attempt moving readme file
krisantrobus Dec 18, 2024
cb349f9
chore(docs): use cwd
krisantrobus Dec 18, 2024
ed7ec6d
chore(docs): debug
krisantrobus Dec 18, 2024
24f2da3
chore(docs): debug
krisantrobus Dec 18, 2024
e1914de
chore(docs): debug
krisantrobus Dec 18, 2024
acdc43a
chore(docs): debug
krisantrobus Dec 18, 2024
78eae0b
chore(docs): debug
krisantrobus Dec 18, 2024
0b27cea
chore(docs): debug
krisantrobus Dec 18, 2024
26b531d
chore(docs): debug
krisantrobus Dec 18, 2024
9e58d87
chore(docs): debug
krisantrobus Dec 19, 2024
7a1a3ec
chore(docs): debug
krisantrobus Dec 19, 2024
3389b32
chore(docs): debug
krisantrobus Dec 19, 2024
e414dc9
chore(docs): debug
krisantrobus Dec 19, 2024
d1f8da7
chore(docs): debug
krisantrobus Dec 19, 2024
386abdb
chore(docs): debug
krisantrobus Dec 19, 2024
da482c5
chore(docs): debug
krisantrobus Dec 19, 2024
677d12f
chore(docs): debug
krisantrobus Dec 19, 2024
9df3799
chore(docs): debug
krisantrobus Dec 20, 2024
30b3592
chore(docs): debug
krisantrobus Dec 20, 2024
b2344a5
chore(docs): debug
krisantrobus Dec 20, 2024
ac9f21c
chore(docs): debug
krisantrobus Dec 20, 2024
78cca51
chore(docs): final sitemap
krisantrobus Dec 20, 2024
5e75bc2
Merge branch 'main' into fix-sitemap-locally
kodiakhq[bot] Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/integration/sitemap-vrt/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export const SITEMAP = [
"/tokens/",
];

const SITEMAP_CHUNKS: string[][] = [];
const SITEMAP_CHUNKS = [];
const CHUNK_SIZE = 25;

for (let i = 0, len = SITEMAP.length; i < len; i += CHUNK_SIZE) {
Expand Down
33 changes: 6 additions & 27 deletions packages/paste-website/src/pages/sitemap.xml.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,25 @@
import { globby } from "globby-esm";
import type { GetServerSideProps } from "next";
import { unstable_noStore as noStore } from "next/cache";

import { SITEMAP } from "../../../../cypress/integration/sitemap-vrt/constants"; // Import the SITEMAP used for cypress

const Sitemap = (): React.ReactElement | null => {
return 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(["**/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 = `<?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
Loading