-
Notifications
You must be signed in to change notification settings - Fork 0
/
next-sitemap.config.js
43 lines (38 loc) · 1.16 KB
/
next-sitemap.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const fs = require('fs')
const path = require('path')
/** @type {import("next-sitemap").IConfig} */
module.exports = {
siteUrl: process.env.SITE_URL || 'https://lib.kyokko.work',
outDir: './.next',
// ...other options
additionalPaths: async () => {
return await generateSSRPaths()
},
}
const generateSSRPaths = async () => {
const paths = []
const markets = ['us', 'jp']
markets.flatMap((market) => {
return fs
.readdirSync(`./data/${market}/techs/companies`)
.map((file) => {
return file.replace('.json', '')
})
.map((file) => {
paths.push({ loc: `/ja/${market}/techs/companies/${file}` })
})
})
markets.flatMap((market) => {
return fs.readdirSync(`./data/${market}/techs/techs`).map((dir) => {
const files = fs.readdirSync(
path.join(`./data/${market}/techs/techs`, dir)
)
const json = JSON.parse( fs.readFileSync(path.join(`./data/${market}/techs/techs/${dir}`, files[0]), 'utf8'))
const otherInitials = json.otherInitials
otherInitials.map((initial) => {
paths.push({ loc: `/ja/${market}/techs/${dir}/${initial}` })
})
})
})
return paths
}