Add sitemap, generated at build time

This commit is contained in:
Tyler Hallada 2022-02-13 23:45:41 -05:00
parent 9f46000eff
commit 452799192a
3 changed files with 3740 additions and 17 deletions

34
next-sitemap.config.js Normal file
View File

@ -0,0 +1,34 @@
/** @type {import('next-sitemap').IConfig} */
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
const MOD_SEARCH_INDEX_URL = 'https://mods.modmapper.com/mod_search_index.json';
module.exports = {
siteUrl: process.env.SITE_URL || 'https://modmapper.com',
generateRobotsTxt: true,
additionalPaths: async (config) => {
console.log("additional paths");
const result = []
const response = await fetch(MOD_SEARCH_INDEX_URL);
const index = await response.json();
for (const mod of index) {
result.push({
loc: '/?mod=' + mod.id,
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
},
}

3720
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"postbuild": "next-sitemap --config next-sitemap.config.js",
"start": "next start",
"lint": "next lint"
},
@ -26,6 +27,8 @@
"@types/react-dom": "^17.0.11",
"eslint": "8.6.0",
"eslint-config-next": "12.0.8",
"next-sitemap": "^2.1.14",
"node-fetch": "^3.2.0",
"typescript": "4.5.4"
}
}