This repository has been archived by the owner on Oct 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
nuxt.config.js
99 lines (92 loc) · 2.46 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
const StoryblokClient = require('storyblok-js-client')
// !!! Change to your Storyblok preview token
const StoryblokToken = 'R5hUgUB9PGoRq2XwtYw14wtt'
module.exports = {
/*
** Headers of the page
*/
head: {
title: 'NuxtDoc - Combining Nuxt.js, Storyblok and Netlify',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'A setup to build beautiful documentation with Nuxt and Storyblok deployed on Netlify' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Customize the progress bar color
*/
loading: { color: '#3B8070' },
/*
** Build configuration
*/
router: {
middleware: [ 'navigation-loader', 'cache-version-loader' ],
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
let position = {}
if (to.matched.length < 2) {
position = { x: 0, y: 0, offset: { x: 0, y: 80 } }
} else if (to.matched.some(r => r.components.default.options.scrollToTop)) {
position = { x: 0, y: 0 }
}
if (to.hash) {
position = { selector: to.hash, offset: { x: 0, y: 80 } }
}
return position
}
}
},
css: [
'@/assets/_variables.scss'
],
plugins: [
'@/plugins/components'
],
modules: [
['storyblok-nuxt', {accessToken: 'R5hUgUB9PGoRq2XwtYw14wtt', cacheProvider: 'memory'}]
],
generate: {
routes() {
const client = new StoryblokClient({
accessToken: StoryblokToken
})
let page = 1
let routes = [
'/v1/menu'
]
let results = []
let count = 0
let version = 'published'
const getItems = (page = 1) => {
return client.get('cdn/links', {
version,
page
}).then(res => {
let links = Object.values(res.data.links)
results.push(...links)
count += links.length
if (count !== res.total && page <= Math.ceil(res.total / res.perPage)) {
return getItems(page + 1)
}
})
}
return getItems()
.then(() => {
results.forEach((link) => {
routes.push('/' + (link.slug == 'home' ? '' : link.slug))
})
return routes
})
}
},
build: {
extend (config, { isDev, isClient }) {
}
}
}