-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
61 lines (56 loc) · 1.07 KB
/
routes.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
const set = require('lodash/set');
const routes = require('next-routes')();
const { VALID_LOCALES, TOPICS, NY2021 } = require('./constants');
const langs = VALID_LOCALES.join('|');
const topics = TOPICS.join('|');
const ROUTES = [
{
name: 'main',
pattern: '',
page: 'index',
},
{
name: 'article',
pattern: '/article/:slug',
},
{
name: 'topic',
pattern: `/topic/:topic(${topics})`,
},
{
name: 'tag',
pattern: `/topic/:topic(${topics})/tag/:tag`,
},
{
name: 'collection',
pattern: '/collection/:slug',
},
{
name: 'about',
},
{
name: 'diary',
pattern: '/diary/:slug?',
},
{
name: 'status',
pattern: '/status/:code(404|500)',
},
{
name: `game/${NY2021}`,
},
{
name: 'game/tinder',
},
].map(({ name, pattern = `/${name}`, page = name }) => ({
name,
pattern: `/:lang(${langs})${pattern}`,
page,
}));
const ROUTES_NAMES = {};
ROUTES.forEach(route => {
set(ROUTES_NAMES, route.name, route.name);
routes.add(route);
});
routes.ROUTES_NAMES = ROUTES_NAMES;
module.exports = routes;