Skip to content

Commit 3892efd

Browse files
committed
Update blockchains/sitemap.xml to include extended chain pages
1 parent 6c5e84d commit 3892efd

File tree

1 file changed

+9
-7
lines changed
  • src/routes/trading-view/blockchains/sitemap.xml

1 file changed

+9
-7
lines changed

src/routes/trading-view/blockchains/sitemap.xml/+server.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
* Generate sitemap with entries for each chain
33
*/
44
import { SitemapStream } from 'sitemap';
5-
import { fetchPublicApi } from '$lib/helpers/public-api';
5+
import { chains } from '$lib/helpers/chain';
66

7-
const chainPages = ['', 'exchanges', 'lending', 'tokens', 'trading-pairs'];
87
const path = 'trading-view';
98
const priority = 0.8;
109

1110
export async function GET({ fetch, setHeaders, url, route }) {
12-
const chains = await fetchPublicApi(fetch, 'chains');
13-
1411
const stream = new SitemapStream({ hostname: url.origin });
1512

16-
for (const { chain_slug } of chains) {
17-
for (const page of chainPages) {
18-
const url = [path, chain_slug, page].filter(Boolean).join('/');
13+
for (const chain of chains) {
14+
const chainUrl = `${path}/${chain.slug}`;
15+
stream.write({ url: chainUrl, priority });
16+
17+
const pages = chain.hasBackendData ? ['exchanges', 'lending', 'tokens', 'trading-pairs', 'vaults'] : ['vaults'];
18+
19+
for (const page of pages) {
20+
const url = `${chainUrl}/${page}`;
1921
stream.write({ url, priority });
2022
}
2123
}

0 commit comments

Comments
 (0)