Repository navigation
Expand file tree
/
Copy pathstatic.config.js
More file actions
134 lines (132 loc) · 3.38 KB
/
Copy pathstatic.config.js
File metadata and controls
134 lines (132 loc) · 3.38 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { getContent, getPortfolioContent, getPortfolioLinks } from './src/utils/content'
import Document from './src/Document'
export default {
Document,
siteRoot: process.env.SITE_ROOT,
getSiteData: async () => {
const portfolioLinks = await getPortfolioLinks()
return {
portfolioLinks,
}
},
getRoutes: async () => {
const about = await getContent('about')
const posts = await getContent('blog')
const quotes = await getContent('quotes')
const testimonials = await getContent('testimonials')
const portfolio = await getPortfolioContent()
const categories = posts.reduce((memo, post) => {
if (!memo.find(p => p.category === post.category)) {
memo.push({ category: post.category, slug: post.categorySlug })
}
return memo
}, [])
const archives = posts.reduce((memo, post) => {
const year = new Date(post.date).getFullYear()
if (!memo.includes(year)) memo.push(year)
return memo
}, [])
return [
{
path: '/',
template: 'src/containers/Home',
localProps: {
portfolio,
quotes,
testimonials,
},
getData: () => ({
portfolio,
quotes,
testimonials,
}),
children: portfolio.map(detail => ({
path: `services/${detail.slug}`,
template: 'src/containers/Service',
localProps: { detail },
getData: () => ({
detail,
}),
})),
},
{
path: '/services',
redirect: '/',
},
{
path: '/contact',
template: 'src/containers/Contact',
},
{
path: '/about',
template: 'src/containers/About',
localProps: { about },
getData: () => ({
about,
}),
},
{
path: '/blog',
template: 'src/containers/Blog',
localProps: { posts },
getData: () => ({
posts,
}),
children: posts.map(post => ({
path: `/post/${post.slug}`,
template: 'src/containers/Post',
localProps: { posts, post },
getData: () => ({
posts,
post,
}),
})),
},
{
path: '/blog/category',
template: 'src/containers/Blog',
redirect: '/blog',
localProps: { posts },
getData: () => ({
posts,
}),
children: categories.map(category => ({
path: `/${category.slug}`,
template: 'src/containers/Blog',
localProps: { posts, category },
getData: () => ({
posts,
category,
}),
})),
},
{
path: '/blog/archive',
template: 'src/containers/Blog',
redirect: '/blog',
localProps: { posts },
getData: () => ({
posts,
}),
children: archives.map(archive => ({
path: `/${archive}`,
template: 'src/containers/Blog',
localProps: { posts, archive },
getData: () => ({
posts,
archive,
}),
})),
},
{
path: '404',
template: 'src/containers/404',
},
]
},
plugins: [
require.resolve('react-static-plugin-sass'),
require.resolve('react-static-plugin-react-router'),
require.resolve('react-static-plugin-sitemap')
]
}