-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.js
118 lines (98 loc) · 3.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import Prismic from '@prismicio/client'
import sm from './sm.json'
export default async () => {
const client = await Prismic.getApi(sm.apiEndpoint)
const locales = client.languages.map(lang => lang.id)
const defaultLocale = locales[0]
return {
// Target: https://go.nuxtjs.dev/config-target
target: 'static',
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'Prismic + Nuxt i18n example',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: 'Prismic + Nuxt i18n example'
},
{ name: 'format-detection', content: 'telephone=no' }
],
link: [{ rel: 'icon', type: 'image/png', href: '/favicon.png' }]
},
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: ['@nuxt/postcss8'],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'@nuxtjs/i18n',
/* Load Prismic module after i18n module to prevent extend route concurrency */ '@nuxtjs/prismic'
],
build: {
postcss: {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
},
transpile: ['@prismicio/vue']
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'@/styles/global.css',
'@fontsource/inter/400.css',
'@fontsource/inter/600.css',
'@fontsource/libre-baskerville/400.css',
'@fontsource/libre-baskerville/400-italic.css',
'@fontsource/libre-baskerville/700.css',
'flag-icons/css/flag-icons.css'
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
i18n: {
locales,
defaultLocale
},
prismic: {
endpoint: sm.apiEndpoint,
modern: true,
linkResolver: (doc) => {
const prefix = doc.lang === 'en-us' ? '' : `/${doc.lang}`
switch (doc.type) {
case 'page':
return doc.uid === 'home' ? prefix || '/' : `${prefix}/${doc.uid}`
default:
return prefix || '/'
}
},
htmlSerializer (type, element, content, children) {
switch (type) {
case 'paragraph':
return /* html */ `<p class="mb-7 last:mb-0">${children.join('')}</p>`
case 'group-o-list-item':
return /* html */ `<ol class="mb-7 pl-4 last:mb-0 md:pl-6">${children.join('')}</ol>`
case 'o-list-item':
return /* html */ `<li class="mb-1 list-decimal pl-1 last:mb-0 md:pl-2">${children.join('')}</li>`
case 'group-list-item':
return /* html */ `<ul class="mb-7 pl-4 last:mb-0 md:pl-6">${children.join('')}</ul>`
case 'list-item':
return /* html */ `<li class="mb-1 list-disc pl-1 last:mb-0 md:pl-2">${children.join('')}</li>`
case 'preformatted':
return /* html */ `<pre class="mb-7 rounded bg-slate-100 p-4 text-sm last:mb-0 md:p-8 md:text-lg">
<code>${children.join('')}</code>
</pre>`
case 'strong':
return /* html */ `<strong class="font-semibold">${children.join('')}</strong>`
case 'hyperlink':
return /* html */ `<a href="${element.data.url}" class="underline decoration-1 underline-offset-2">${children.join('')}</a>`
default:
return null
}
}
}
}
}