-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
166 lines (137 loc) · 3.8 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// const pkg = require('./package')
import Mode from "frontmatter-markdown-loader/mode"
import projects from './pages/portfolio/list.js'
const routerBase = process.env.DEPLOY_ENV === 'GH_PAGES' ? {
base: '/chase/'
} : {}
export default {
mode: "universal",
// Headers of the page
// head: {
// title: pkg.name,
// meta: [
// { charset: "utf-8" },
// { name: "viewport", content: "width=device-width, initial-scale=1" },
// { hid: "description", name: "description", content: pkg.description }
// ],
// link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }]
// },
// Customize the progress-bar color
loading: false,
head: {
titleTemplate: titleChunk => {
return titleChunk ? `${titleChunk} - Chase Whiteside` : "Chase Whiteside";
},
meta: [
{ charset: "utf-8" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
{
hid: "description",
name: "description",
content: "Personal site of Chase Whiteside"
}
],
link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }]
},
router: {
...routerBase,
middleware: ["routeDepth"],
// scrollBehavior: function(to, from, savedPosition) {
// return new Promise(resolve => {
// if (savedPosition) {
// resolve(savedPosition);
// } else {
// resolve({ x: 0, y: 0 });
// }
// });
// }
scrollBehavior(to, from, savedPosition) {
let savedScrollPositions = this.app.$root.scroll_positions
if (from.meta.saveScrollPosition) {
savedScrollPositions[from.name] = {
x: document.documentElement.scrollLeft,
y: document.documentElement.scrollTop
}
}
if (savedPosition) {
return savedPosition
} else {
}
if (savedPosition) {
// savedPosition is only available for popstate navigations.
return savedPosition
} else {
const position = {}
// scroll to anchor by returning the selector
if (to.hash) {
position.selector = `[id='${to.hash}']`
// specify offset of the element
if (to.hash === '#anchor2') {
position.offset = { y: 100 }
}
// bypass #1number check
// if (/^#\d/.test(to.hash) || document.querySelector(to.hash)) {
if (document.querySelector(`[id='${to.hash}']`)) {
return position
}
// if the returned position is falsy or an empty object,
// will retain current scroll position.
return false
}
else {
return to.meta.saveScrollPosition && savedScrollPositions.hasOwnProperty(to.name) ? savedScrollPositions[to.name] : { x: 0, y: 0 }
}
}
},
},
generate: {
},
// Global CSS
css: [
"~/styles/global.scss",
"~/styles/projects/projects.scss"
],
modules: [
'@nuxtjs/style-resources',
'nuxt-responsive-loader'
],
responsiveLoader: {
format: 'jpg',
min: 250,
max: 1000,
steps: 3,
adapter: require("responsive-loader/sharp"),
quality: 75
},
styleResources: {
scss: [
"~/styles/_bitsnpieces.scss",
]
},
// Plugins to load before mounting the App
plugins: [
// { src: "~/plugins/TweenMax", ssr: false }
],
// Build configuration
build: {
extend(config) {
config.module.rules.push({
test: /\.md$/,
loader: 'frontmatter-markdown-loader',
options: {
mode: [Mode.HTML, Mode.VUE_RENDER_FUNCTIONS],
vue: {
root: "DynamicMarkdown"
}
}
})
},
},
generate: {
routes: [
'404'
]
.concat(projects.map(w => `/portfolio/${w}`))
// .concat(blogsEs.map(w => `es/blog/${w}`))
}
};