forked from nuxt/website-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
88 lines (86 loc) · 2.31 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
import axios from 'axios'
import _ from 'lodash'
const locale = process.env.NUXT_LOCALE || 'en'
export default {
modern: 'client',
head: {
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
],
script: [
{ src: 'https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver', body: true }
]
},
css: [
'normalize.css',
'highlight.js/styles/github.css',
'~/assets/scss/main.scss'
],
modules: [
// https://github.com/nuxt-community/style-resources-module
'@nuxtjs/style-resources',
// https://github.com/Developmint/nuxt-svg-loader/
'nuxt-svg-loader',
// https://github.com/DreaMinder/nuxt-payload-extractor
// 'nuxt-payload-extractor'
],
plugins: [
'~/plugins/init.js',
{ src: '~/plugins/ga.client.js', ssr: false },
{ src: '~/plugins/adblock.client.js', ssr: false }
],
env: {
githubToken: '4aa6bcf919d238504e7db59a66d32e78281c0ad3',
docSearchApiKey: 'ff80fbf046ce827f64f06e16f82f1401',
locale
},
loading: { color: '#41B883' },
router: {
// middleware: ['static'],
scrollBehavior(to, from, savedPosition) {
// savedPosition is only available for popstate navigations (back button)
if (savedPosition) {
return savedPosition
}
return { x: 0, y: 0 }
}
},
generate: {
fallback: true,
interval: 100,
routes() {
return Promise.all(
['guide', 'api', 'examples', 'faq']
.map((category) => {
return axios.get(`https://docs.api.nuxtjs.org/menu/${locale}/${category}`)
.then((res) => res.data || [])
.then((menu) => {
return _(menu)
.map('links')
.flatten()
.map((m) => m.to.slice(1))
.compact()
.map((slug) => {
return `/${category}/${slug}`
})
.value()
.concat(`/${category}`)
})
})
)
.then((routes) => _(routes).flatten().uniq().value())
}
},
/*
** Build configuration
*/
styleResources: {
scss: [
'./assets/styles/variables/theme.scss'
]
}
}