-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
124 lines (122 loc) · 2.89 KB
/
nuxt.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
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
// [WprdPress]
const axios = require('axios')
const config = require('./api/wp/config/index')
// [Contentful]
/* const config = require('./api/contentful/config/index')
const contentful = require('./.contentful.js')
const client = require('contentful').createClient({
space: contentful.CTF_SPACE_ID,
accessToken: contentful.CTF_CDA_ACCESS_TOKEN
}) */
module.exports = {
/*
** Headers of the page
*/
head: {
titleTemplate: `%s - ${config.title}`,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: `${config.description}`
}
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
},
/*
** Customize the progress bar color
*/
loading: { color: '#3B8070' },
/*
** Build configuration
*/
build: {
/*
** Run ESLint on save
*/
extend(config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
},
vendor: ['element-ui']
},
plugins: ['~plugins/element-ui', '~/plugins/mixin'],
css: ['element-ui/lib/theme-chalk/index.css'],
modules: [
'@nuxtjs/pwa',
[
'@nuxtjs/google-analytics',
{
id: 'UA-XXXX-XXX'
}
]
],
manifest: {
name: `${config.title}`,
lang: 'ja'
},
// [generate] WordPressの場合
generate: {
interval: 500,
routes: () => {
return Promise.all([
axios.get(`${config.endpoint}/wp/v2/post_all_id`),
axios.get(`${config.endpoint}/wp/v2/page_all_slug`)
]).then(data => {
const posts = data[0]
const pages = data[1]
return posts.data
.map(post => {
return {
route: '/post/' + post.id,
payload: post
}
})
.concat(
pages.data.map(page => {
return {
route: page.slug,
payload: page
}
})
)
})
}
}
// [generate] Contentfulの場合
/* generate: {
interval: 500,
routes: () => {
return Promise.all([
client.getEntries({ content_type: contentful.CTF_POST_TYPE_ID }),
client.getEntries({ content_type: contentful.CTF_PAGE_TYPE_ID })
]).then(data => {
const posts = data[0]
const pages = data[1]
return posts.items
.map(post => {
return {
route: '/post/' + post.sys.id,
payload: post
}
})
.concat(
pages.items.map(page => {
return {
route: page.fields.slug,
payload: page
}
})
)
})
}
} */
}