modmapper-web/next-sitemap.config.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-02-14 04:45:41 +00:00
/** @type {import('next-sitemap').IConfig} */
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
const SSE_MOD_SEARCH_INDEX_URL = 'https://mods.modmapper.com/skyrimspecialedition/mod_search_index.json';
const LE_MOD_SEARCH_INDEX_URL = 'https://mods.modmapper.com/skyrim/mod_search_index.json';
2022-02-14 04:45:41 +00:00
module.exports = {
siteUrl: process.env.SITE_URL || 'https://modmapper.com',
generateRobotsTxt: true,
additionalPaths: async (config) => {
const result = []
const skyrimResponse = await fetch(LE_MOD_SEARCH_INDEX_URL);
const skyrimIndex = await skyrimResponse.json();
2022-02-14 04:45:41 +00:00
const skyrimspecialeditionResponse = await fetch(SSE_MOD_SEARCH_INDEX_URL);
const skyrimspecialeditionIndex = await skyrimspecialeditionResponse.json();
for (const mod of skyrimIndex) {
result.push({
loc: `/?game=skyrim&mod=${mod.id}`,
changefreq: 'daily',
});
}
for (const mod of skyrimspecialeditionIndex) {
2022-02-14 04:45:41 +00:00
result.push({
loc: `/?game=skyrimspecialedition&mod=${mod.id}`,
2022-02-14 04:45:41 +00:00
changefreq: 'daily',
});
}
for (let x = -77; x < 75; x++) {
for (let y = -50; y < 44; y++) {
result.push({
loc: '/?cell=' + encodeURIComponent(`${x},${y}`),
changefreq: 'daily',
});
}
}
return result
},
}