fix: sitemap format (#7453)

This commit is contained in:
eddie 2023-10-11 15:23:15 -07:00 committed by GitHub
parent 40b1e40721
commit 5fee3c6fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1429 additions and 367 deletions

File diff suppressed because it is too large Load Diff

@ -21,11 +21,11 @@ fs.readFile('./public/sitemap.xml', 'utf8', async (err, data) => {
const sitemap = await parseStringPromise(data)
if (sitemap.urlset.url) {
sitemap.urlset.url.forEach((url) => {
const lastMod = new Date(url['$'].lastmod).getTime()
const lastMod = new Date(url.lastmod).getTime()
if (lastMod < Date.now() - weekMs) {
url['$'].lastmod = nowISO
url.lastmod = nowISO
}
sitemapURLs[url['$']['loc']] = true
sitemapURLs[url.loc] = true
})
}
@ -45,11 +45,9 @@ fs.readFile('./public/sitemap.xml', 'utf8', async (err, data) => {
const tokenURL = `https://app.uniswap.org/tokens/${chainName.toLowerCase()}/${address}`
if (!(tokenURL in sitemapURLs)) {
sitemap.urlset.url.push({
$: {
loc: [tokenURL],
lastmod: [nowISO],
priority: [0.8],
},
})
}
})

@ -9,7 +9,7 @@ describe('Routes', () => {
const contents = fs.readFileSync('./public/sitemap.xml', 'utf8')
const sitemap = await parseStringPromise(contents)
const sitemapPaths: string[] = sitemap.urlset.url.map((url: any) => new URL(url['$'].loc).pathname)
const sitemapPaths: string[] = sitemap.urlset.url.map((url: any) => new URL(url.loc).pathname)
sitemapPaths
.filter((p) => !p.includes('/0x'))