-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
64 lines (50 loc) · 1.4 KB
/
next.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const cities = Object.keys(require('./gameconfig.json').availableCities)
function getCityRoutes(cityName) {
const cityRoutes = new Map()
const nbLevels = 3
for (let currentLevel = 1; currentLevel <= nbLevels; currentLevel++) {
cityRoutes.set(`/${cityName}/level/${currentLevel}/index.html`, {
page: '/',
query: {
city: cityName,
level: currentLevel
}
})
}
cityRoutes.set(`/${cityName}/index.html`, {
page: '/',
query: {
city: cityName,
level: 1
}
})
return cityRoutes
}
module.exports = {
// "/test"
assetPrefix: process.env.URL_PREFIX,
publicRuntimeConfig: {
URL_PREFIX: process.env.URL_PREFIX,
ROOT_URL: process.env.ROOT_URL
},
exportPathMap: function () {
let routes = new Map()
routes.set('/', { page: '/' })
routes.set('/about', { page: '/about' })
routes.set('/highscores', { page: '/highscores' })
let allCitiesRoutes = cities.map(city => getCityRoutes(city))
allCitiesRoutes.forEach(cityRoutes => {
cityRoutes.forEach((value, key) => {
routes.set(key, value)
})
})
// Convert to object literal map
// https://gist.github.com/lukehorvat/133e2293ba6ae96a35ba
let routesObjLiteral = Array.from(routes).reduce(
(obj, [key, value]) => Object.assign(obj, { [key]: value }),
{}
)
console.log(routesObjLiteral)
return routesObjLiteral
}
}