|
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,20 @@ 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.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 | + }), |
95 | 101 | ...allChains.map((chain) => { |
96 | 102 | return { |
97 | 103 | loc: `/${chain.slug}`, |
@@ -136,3 +142,19 @@ async function createSearchRecordSitemaps(config) { |
136 | 142 | // filter out any failed requests |
137 | 143 | return chainsForLines.filter(Boolean); |
138 | 144 | } |
| 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 | +} |
0 commit comments