Skip to content

Commit 6636277

Browse files
committed
[TOOL-3876] Dashboard: Merge Framer sitemap.xml to dashboard sitemap.xml (#6648)
<!-- start pr-codex --> ## PR-Codex overview This PR primarily introduces the `fast-xml-parser` package to the project and updates the `fetchChainsFromApi` function to fetch and parse XML data. It also modifies the sitemap generation logic to utilize the newly added functionality. ### Detailed summary - Added `fast-xml-parser` to `package.json` and `pnpm-lock.yaml`. - Updated `next-sitemap.config.js` to require `fast-xml-parser`. - Introduced a new function `getFramerXML` to fetch and parse XML data. - Modified `additionalPaths` to use data from `getFramerXML`. - Adjusted the return structure of URLs in `additionalPaths`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 8f7bcae commit 6636277

File tree

4 files changed

+70
-30
lines changed

4 files changed

+70
-30
lines changed

apps/dashboard/knip.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"ignoreDependencies": [
1313
"@storybook/blocks",
1414
"@thirdweb-dev/service-utils",
15-
"@types/color"
15+
"@types/color",
16+
"fast-xml-parser"
1617
]
1718
}

apps/dashboard/next-sitemap.config.js

Lines changed: 32 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,20 @@ 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.map((url) => {
94+
return {
95+
loc: url.loc,
96+
changefreq: config.changefreq,
97+
priority: config.priority,
98+
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
99+
};
100+
}),
95101
...allChains.map((chain) => {
96102
return {
97103
loc: `/${chain.slug}`,
@@ -136,3 +142,19 @@ async function createSearchRecordSitemaps(config) {
136142
// filter out any failed requests
137143
return chainsForLines.filter(Boolean);
138144
}
145+
146+
async function getFramerXML() {
147+
const framerSiteMapText = await fetch(
148+
"https://landing.thirdweb.com/sitemap.xml",
149+
).then((res) => res.text());
150+
151+
const parser = new XMLParser();
152+
const xmlObject = parser.parse(framerSiteMapText);
153+
154+
/**
155+
* @type {Array<{loc: string}>}
156+
*/
157+
const urls = xmlObject.urlset.url;
158+
159+
return urls;
160+
}

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)