Generate a sitemap with next-sitemap
This commit is contained in:
parent
1374309de3
commit
1a1dc97ec8
43
web/next-sitemap.js
Normal file
43
web/next-sitemap.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const https = require('https')
|
||||
|
||||
/** @type {import('next-sitemap').IConfig} */
|
||||
|
||||
module.exports = {
|
||||
siteUrl: process.env.SITE_URL || 'https://manifold.markets',
|
||||
changefreq: 'hourly',
|
||||
priority: 0.7, // Set high priority by default
|
||||
additionalPaths,
|
||||
exclude: ['/admin'],
|
||||
generateRobotsTxt: true,
|
||||
// Other options: https://github.com/iamvishnusankar/next-sitemap#configuration-options
|
||||
}
|
||||
|
||||
// See https://github.com/iamvishnusankar/next-sitemap#additional-paths-function
|
||||
async function additionalPaths(config) {
|
||||
// Fetching data from https://docs.manifold.markets/api
|
||||
const response = await fetch(`${config.siteUrl}/api/v0/markets`)
|
||||
|
||||
const liteMarkets = await response
|
||||
// See https://www.sitemaps.org/protocol.html
|
||||
return liteMarkets.map((liteMarket) => ({
|
||||
loc: liteMarket.url,
|
||||
changefreq: 'hourly',
|
||||
priority: 0.2, // Individual markets aren't that important
|
||||
// TODO: Add `lastmod` aka last modified time
|
||||
}))
|
||||
}
|
||||
|
||||
// Polyfill for fetch: get the JSON contents of a URL
|
||||
async function fetch(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
https.get(url, (res) => {
|
||||
let data = ''
|
||||
res.on('data', (chunk) => {
|
||||
data += chunk
|
||||
})
|
||||
res.on('end', () => {
|
||||
resolve(JSON.parse(data))
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
|
@ -12,7 +12,8 @@
|
|||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"format": "npx prettier --write .",
|
||||
"prepare": "cd .. && husky install web/.husky"
|
||||
"prepare": "cd .. && husky install web/.husky",
|
||||
"postbuild": "next-sitemap"
|
||||
},
|
||||
"dependencies": {
|
||||
"@headlessui/react": "1.4.2",
|
||||
|
@ -44,6 +45,7 @@
|
|||
"eslint-config-next": "12.0.4",
|
||||
"husky": "7.0.4",
|
||||
"lint-staged": "12.1.3",
|
||||
"next-sitemap": "^2.5.14",
|
||||
"postcss": "8.3.5",
|
||||
"prettier": "2.5.0",
|
||||
"prettier-plugin-tailwindcss": "^0.1.5",
|
||||
|
|
18
yarn.lock
18
yarn.lock
|
@ -72,6 +72,11 @@
|
|||
"@babel/helper-validator-identifier" "^7.14.9"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@corex/deepmerge@^2.6.148":
|
||||
version "2.6.148"
|
||||
resolved "https://registry.yarnpkg.com/@corex/deepmerge/-/deepmerge-2.6.148.tgz#8fa825d53ffd1cbcafce1b6a830eefd3dcc09dd5"
|
||||
integrity sha512-6QMz0/2h5C3ua51iAnXMPWFbb1QOU1UvSM4bKBw5mzdT+WtLgjbETBBIQZ+Sh9WvEcGwlAt/DEdRpIC3XlDBMA==
|
||||
|
||||
"@eslint/eslintrc@^0.4.3":
|
||||
version "0.4.3"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c"
|
||||
|
@ -4322,6 +4327,11 @@ minimist@^1.1.1, minimist@^1.2.0:
|
|||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||
|
||||
minimist@^1.2.6:
|
||||
version "1.2.6"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
||||
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
||||
|
||||
mri@^1.1.5:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b"
|
||||
|
@ -4373,6 +4383,14 @@ netmask@^1.0.6:
|
|||
resolved "https://registry.yarnpkg.com/netmask/-/netmask-1.0.6.tgz#20297e89d86f6f6400f250d9f4f6b4c1945fcd35"
|
||||
integrity sha1-ICl+idhvb2QA8lDZ9Pa0wZRfzTU=
|
||||
|
||||
next-sitemap@^2.5.14:
|
||||
version "2.5.14"
|
||||
resolved "https://registry.yarnpkg.com/next-sitemap/-/next-sitemap-2.5.14.tgz#f196c90d4aef8444c6eb7266875bf2179a515bb7"
|
||||
integrity sha512-aJmxGmoE23NClCi1P6KpHov9DUieF/ZZbfGpTiruOYCq4nKu8Q4masOuswlOl3nNKZa0C3u4JG+TPubjslYH9A==
|
||||
dependencies:
|
||||
"@corex/deepmerge" "^2.6.148"
|
||||
minimist "^1.2.6"
|
||||
|
||||
next@12.0.7:
|
||||
version "12.0.7"
|
||||
resolved "https://registry.yarnpkg.com/next/-/next-12.0.7.tgz#33ebf229b81b06e583ab5ae7613cffe1ca2103fc"
|
||||
|
|
Loading…
Reference in New Issue
Block a user