|
1 | 1 | // @ts-check |
| 2 | +// eslint-disable-next-line @typescript-eslint/no-var-requires |
| 3 | +const { XMLParser } = require("fast-xml-parser"); |
2 | 4 |
|
3 | 5 | /** |
4 | | - * |
| 6 | + * @returns {Promise<Array<{chainId: number, name: string, slug: string}>>} |
5 | 7 | */ |
6 | 8 | async function fetchChainsFromApi() { |
7 | 9 | const res = await fetch("https://api.thirdweb.com/v1/chains", { |
@@ -82,16 +84,13 @@ module.exports = { |
82 | 84 | }; |
83 | 85 | }, |
84 | 86 | 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 | + |
88 | 92 | 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, |
95 | 94 | ...allChains.map((chain) => { |
96 | 95 | return { |
97 | 96 | loc: `/${chain.slug}`, |
@@ -136,3 +135,19 @@ async function createSearchRecordSitemaps(config) { |
136 | 135 | // filter out any failed requests |
137 | 136 | return chainsForLines.filter(Boolean); |
138 | 137 | } |
| 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 | +} |
0 commit comments