-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnuxt.config.ts
263 lines (254 loc) · 6.59 KB
/
nuxt.config.ts
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// https://nuxt.com/docs/api/configuration/nuxt-config
import { join, sep } from "path";
import { globSync } from "glob";
import { pathExists, copy } from "fs-extra";
import type { LocaleObject, Directions } from "vue-i18n-routing";
// List of supported languages
const locales: LocaleObject[] = [
{
code: "en",
iso: "en-US",
name: "English",
file: "en.json",
},
{
code: "fr",
name: "Français",
iso: "fr-FR",
file: "fr.json",
},
{
code: "de",
name: "Deutsch",
iso: "de-DE",
file: "de.json",
},
{
code: "ru",
name: "Русский",
iso: "ru-RU",
file: "ru.json",
},
{
code: "he",
name: "עִברִית",
iso: "he-IL",
file: "he.json",
dir: "rtl" as Directions,
},
{
code: "ar",
name: "العربية الفصحى",
iso: "ar-001",
file: "ar.json",
dir: "rtl" as Directions,
},
{
code: "es",
name: "Español",
iso: "es-ES",
file: "es.json",
},
/*
{
code: "pt",
name: "Português",
iso: "pt-PT",
file: "pt.json",
},
*/
{
code: "zh",
name: "中文(繁體)",
iso: "zh-CN",
file: "zh.json",
},
{
code: "jp",
name: "日本語",
iso: "ja-JP",
file: "jp.json",
},
].sort((a, b) => a.code.localeCompare(b.code));
const publicWebUrl = process.env.PUBLIC_WEB_URL || "https://beam.mw";
// https://github.com/nuxt/content/issues/1551#issuecomment-1470246543
// Added README to index replacement (as understood by the slug)
const docsRoutes = globSync("./content/**/*.md").map((path) =>
path
.slice(7, -3)
.replace(/^\d+\./, "")
.replace(/\\/g, "/")
.replace("/README", "/index"),
);
const copyDocsAssetsToPublic = async () => {
const docsPath = join(process.cwd(), "content", "docs");
const publicAssetsPath = join(process.cwd(), "public", "assets", "docs");
// Find all .gitbook/assets folders within the subdirectories of 'content/docs'
const gitbookAssetsFolders = globSync("**/.gitbook/assets", {
cwd: docsPath,
});
// Iterate over the .gitbook/assets folders and copy their contents
for (const gitbookAssetsFolder of gitbookAssetsFolders) {
const source = join(docsPath, gitbookAssetsFolder);
// Get the parent directory name without the '.gitbook/assets' part
const destinationFolder = gitbookAssetsFolder.replace(
`${sep}.gitbook${sep}assets`,
"",
);
const destination = join(publicAssetsPath, destinationFolder);
// Check if the destination folder exists
const folderExists = await pathExists(destination);
// If the destination folder doesn't exist, copy the contents of the .gitbook/assets folder to the destination folder
if (!folderExists) {
await copy(source, destination);
// eslint-disable-next-line no-console
console.log(`Contents of ${source} copied to ${destination}.`);
}
}
};
export default defineNuxtConfig({
ssr: true,
app: {
pageTransition: false, // Enable later
layoutTransition: false,
},
experimental: {
viewTransition: true,
},
modules: [
"@nuxtjs/tailwindcss",
"@nuxtjs/i18n",
"@nuxtjs/device",
"nuxt-simple-sitemap",
"nuxt-simple-robots",
"nuxt-seo-experiments",
"nuxt-security",
"@nuxtjs/fontaine",
"@nuxt/content",
"nuxt-multi-cache",
],
multiCache: {
component: {
// If true the cache is enabled.
// If false the cache is disabled, but the component is still added to
// the build.
enabled: true,
},
},
security: {
nonce: true,
ssg: {
hashScripts: true, // In the SSG case, inline scripts generated by the server will be allowed by hash
},
rateLimiter: false,
sri: true,
headers: {
contentSecurityPolicy: {
"connect-src":
"'self' https://api.coingecko.com https://dex.beam.mw https://builds.beam.mw",
"script-src": [
"'nonce-{{nonce}}'", // Nonce placeholders in the SSR case will allow inline scripts generated on the server
// "'strict-dynamic'", // Use strict dynamic as outlined here: https://nuxt-security.vercel.app/documentation/advanced/strict-csp#strict-dynamic-csp-level-3
"'self'", // Allow external scripts from self origin
],
"worker-src": "'self' blob:",
"frame-ancestors": false, // This one doesn't work when CSP is in Meta
},
},
removeLoggers: {
external: [],
consoleType: ["log", "debug"],
include: [/\.[jt]sx?$/, /\.vue\??/],
exclude: [/node_modules/, /\.git/],
},
},
nitro: {
prerender: {
routes: [...docsRoutes],
crawlLinks: true,
failOnError: false,
},
},
hooks: {
"build:before": async () => {
await copyDocsAssetsToPublic();
},
},
runtimeConfig: {
public: {
siteUrl: publicWebUrl,
baseURL: publicWebUrl,
},
},
content: {
documentDriven: false,
},
site: {
siteUrl: publicWebUrl,
},
sitemap: {
discoverImages: false,
autoLastmod: true,
credits: false,
},
typescript: {
typeCheck: true,
strict: true,
},
fontMetrics: {
fonts: [
{ family: "ProximaNova", src: "/fonts/ProximaNova-Regular.woff2" },
{
family: "ProximaNova-Italic",
src: "/fonts/ProximaNova-RegularIt.woff2",
},
{ family: "ProximaNova-Bold", src: "/fonts/ProximaNova-Bold.woff2" },
],
},
i18n: {
baseUrl: publicWebUrl,
skipSettingLocaleOnNavigate: false,
defaultLocale: "en",
lazy: true,
langDir: "locales",
vueI18n: "./i18n.config.ts",
customRoutes: "config", // Disable custom route with page components
strategy: "prefix_and_default",
pages: {
downloads: {
en: "/downloads",
fr: "/telechargements",
zh: "/下载",
jp: "/ダウンロード",
de: "/downloads",
ru: "/загрузки",
he: "/הורדות",
ar: "/تنزيلات",
es: "/descargas",
},
"privacy-policy": {
en: "/privacy-policy",
fr: "/politique-de-confidentialite",
zh: "/隐私政策",
jp: "/プライバシーポリシー",
de: "/datenschutzrichtlinie",
ru: "/политикаконфиденциальности",
he: "/מדיניותפרטיות",
ar: "/سياسةالخصوصية",
es: "/politica-de-privacidad",
},
mining: {
en: "/mining",
fr: "/minage",
zh: "/挖矿",
jp: "/マイニング",
de: "/mining",
ru: "/майнинг",
he: "/כרייה",
ar: "/تعدين",
es: "/mineria",
},
},
locales,
},
});