-
Notifications
You must be signed in to change notification settings - Fork 10
/
nuxt.config.js
221 lines (208 loc) · 5.64 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import { $content } from '@nuxt/content'
import reading from 'reading-time'
import pkg from './package'
import formatTime from './helpers/formatTime'
export default {
target: 'static',
components: true,
router: {
middleware: 'tab'
},
/*
** Headers of the page
*/
head: {
title: 'Maya Shavin - Web developer | Speaker | Blogger | Bookworm',
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/png',
href:
'https://res.cloudinary.com/mayashavin/image/upload/w_16,c_fit/v1539936657/mayashavin/rainbow.png'
}
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
css: ['~/assets/css/tailwind.css'],
plugins: ['~/plugins/i18n'],
modules: [
'@nuxt/content',
'@nuxtjs/feed',
'@nuxtjs/sitemap',
'@nuxtjs/robots'
],
build: {
/*
** You can extend webpack config here
*/
extend(config, ctx) {
// Run ESLint on save
if (ctx.isDev && ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
},
buildModules: [
'@nuxtjs/color-mode',
'@nuxtjs/google-analytics',
'@nuxtjs/tailwindcss',
'@nuxtjs/pwa',
'@nuxt/image'
],
purgeCSS: {
whitelist: ['dark-mode', 'bg-mayas-green-dark']
},
pwa: {
meta: {
name: 'Maya Shavin - Web developer | Speaker | Blogger | Bookworm',
description: 'Everything about me as Web developer, blogger and speaker',
ogImage:
'https://res.cloudinary.com/mayashavin/image/upload/q_auto,f_auto/v1595759984/mayashavin/portfolio_cover_2.jpg',
ogHost: 'https://mayashavin.com',
twitterCard: 'summary_large_image',
twitterSite: '@MayaShavin',
twitterCreator: '@MayaShavin'
},
manifest: {
name: 'Maya Shavin - Web developer | Speaker | Blogger | Bookworm',
short_name: 'Maya Shavin - Web developer',
description: 'Everything about me as Web developer, blogger and speaker',
theme_color: '#a069e8'
}
},
content: {
dir: 'content',
liveEdit: false,
// Only search in title and description
fullTextSearchFields: ['title', 'description'],
markdown: {
remarkExternalLinks: {
target: '_blank',
rel: 'noopener noreferrer'
},
remarkPlugins: [
// ['remark-emoji', { emoticon: true }],
// ['remark-footnotes', { inlineNotes: true }]
],
prism: {
theme: 'prism-themes/themes/prism-a11y-dark.css'
}
}
},
image: {
provider: 'cloudinary',
cloudinary: {
baseURL: 'https://res.cloudinary.com/mayashavin/image/upload/'
}
},
hooks: {
'content:file:beforeInsert': document => {
if (document.extension === '.md') {
const { text } = reading(document.text)
document.readingTime = text
}
if (document.slug === 'events') {
const events = document.events
document.events = events.map(event => {
const date = formatTime(new Date(event.organizer.date))
return {
organizer: { ...event.organizer, time: date },
talk: event.talk
}
})
}
if (['.md', '.yaml'].includes(document.extension)) {
if (document.publishedAt) {
document.publishedAt = new Date(document.publishedAt)
}
const time = formatTime(
document.publishedAt
? new Date(document.publishedAt)
: document.createdAt || document.updatedAt
)
document.publishedTime = `${time.month} ${time.day}, ${time.year}`
}
}
},
feed: async () => {
const { tags } = await $content('posts/tags').fetch()
const posts = await $content('posts', { deep: true, text: true })
.where({
extension: '.md'
})
.fetch()
return tags.map(tag => {
const relevantPosts = posts.filter(post => post.tags.includes(tag))
return {
path: `/${tag}.xml`,
create(feed) {
feed.options = {
title: `Category: ${tag} - Maya's Blog`,
link: `https://mayashavin.com/${tag}.xml`,
description: `All post related to ${tag} of my blog`
}
relevantPosts.forEach(post => {
feed.addItem({
title: post.title,
id: post.slug,
link: `https://mayashavin.com/articles/${post.slug}`,
description: post.description,
content: post.text
})
})
},
cacheTime: 1000 * 60 * 15,
type: 'rss2'
}
})
},
sitemap: {
hostname: 'https://mayashavin.com',
exclude: ['/secret', '/admin/**'],
routes: async () => {
const posts = await $content('posts', { deep: true, text: true })
.where({
extension: '.md'
})
.fetch()
return posts.map(post => ({
url: `/articles/${post.slug}`,
lastmod: post.updatedAt || post.createdAt
}))
}
},
googleAnalytics: {
id: process.env.GOOGLE_ANALYTICS_ID,
dev: false,
autoTracking: {
screenview: true,
pageviewTemplate(route) {
return {
page: route.path,
title: document.title,
location: window.location.href
}
},
skipSamePath: true
}
},
publicRuntimeConfig: {
googleAnalytics: {
id: process.env.GOOGLE_ANALYTICS_ID,
dev: false
}
}
}