-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.config.js
55 lines (50 loc) · 1.41 KB
/
static.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
import axios from 'axios'
import path from 'path'
import dotenv from 'dotenv'
dotenv.config()
// import { Post } from './types'
// Typescript support in static.config.js is not yet supported, but is coming in a future update!
const accessToken = process.env.ACCESS_TOKEN
const spaceId = process.env.SPACE_ID
export default {
getSiteData: async ({ dev }) => ({
title: 'Ali Avci\'s personal site',
lastBuilt: Date.now(),
}),
entry: 'index.tsx',
siteRoot: 'https://aliavci.info',
getRoutes: async () => {
const { data: posts } /* :{ data: Post[] } */ = await axios.get(
'https://cdn.contentful.com/spaces/' + spaceId + '/environments/master/entries?access_token=' + accessToken
)
return [
{
path: '/blog',
getData: () => ({
posts,
}),
children: posts.items.map((post /* : Post */) => {
const postFields = post.fields
return ({
path: `/post/${post.sys.id}`,
template: 'src/containers/Post',
getData: () => ({
post,
}),
})
}),
},
]
},
plugins: [
'react-static-plugin-typescript',
[
require.resolve('react-static-plugin-source-filesystem'),
{
location: path.resolve('./src/pages'),
},
],
require.resolve('react-static-plugin-reach-router'),
require.resolve('react-static-plugin-sitemap'),
],
}