Skip to content

Commit 7f32027

Browse files
committed
[TOOL-3876] Dashboard: Merge Framer sitemap.xml to dashboard sitemap.xml
1 parent 8f7bcae commit 7f32027

File tree

3 files changed

+61
-29
lines changed

3 files changed

+61
-29
lines changed

apps/dashboard/next-sitemap.config.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// @ts-check
2+
// eslint-disable-next-line @typescript-eslint/no-var-requires
3+
const { XMLParser } = require("fast-xml-parser");
24

35
/**
4-
*
6+
* @returns {Promise<Array<{chainId: number, name: string, slug: string}>>}
57
*/
68
async function fetchChainsFromApi() {
79
const res = await fetch("https://api.thirdweb.com/v1/chains", {
@@ -82,16 +84,13 @@ module.exports = {
8284
};
8385
},
8486
additionalPaths: async (config) => {
85-
// eslint-disable-next-line @typescript-eslint/no-var-requires
86-
const FRAMER_PATHS = require("./framer-rewrites");
87-
const allChains = await fetchChainsFromApi();
87+
const [framerUrls, allChains] = await Promise.all([
88+
getFramerXML(),
89+
fetchChainsFromApi(),
90+
]);
91+
8892
return [
89-
...FRAMER_PATHS.map((path) => ({
90-
loc: path,
91-
changefreq: config.changefreq,
92-
priority: config.priority,
93-
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
94-
})),
93+
...framerUrls,
9594
...allChains.map((chain) => {
9695
return {
9796
loc: `/${chain.slug}`,
@@ -136,3 +135,19 @@ async function createSearchRecordSitemaps(config) {
136135
// filter out any failed requests
137136
return chainsForLines.filter(Boolean);
138137
}
138+
139+
async function getFramerXML() {
140+
const framerSiteMapText = await fetch(
141+
"https://landing.thirdweb.com/sitemap.xml",
142+
).then((res) => res.text());
143+
144+
const parser = new XMLParser();
145+
const xmlObject = parser.parse(framerSiteMapText);
146+
147+
/**
148+
* @type {Array<{loc: string}>}
149+
*/
150+
const urls = xmlObject.urlset.url;
151+
152+
return urls;
153+
}

apps/dashboard/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"color": "5.0.0",
6060
"compare-versions": "^6.1.0",
6161
"date-fns": "4.1.0",
62+
"fast-xml-parser": "^5.2.0",
6263
"fetch-event-stream": "0.1.5",
6364
"flat": "^6.0.1",
6465
"framer-motion": "12.5.0",

pnpm-lock.yaml

Lines changed: 35 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)