-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnuxt.config.ts
81 lines (80 loc) · 2.48 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
import { defineNuxtConfig } from 'nuxt/config';
import { mkdir, writeFile } from 'node:fs/promises';
import { default as nuxtIcons } from 'nuxt-icons';
import { default as plausible } from '@nuxtjs/plausible';
import { fetchTranslations } from './src/scripts/fetch-translations';
import { fetchBlogFeed } from './src/scripts/fetch-blog-feed';
import { fetchRedirects } from './src/scripts/fetch-redirects';
import { fetchI18nSlugs } from './src/scripts/fetch-i18n-slugs';
import { defaultLanguage } from './src/lib/i18n';
export default defineNuxtConfig({
compatibilityDate: '2025-01-17',
srcDir: 'src',
css: [
'@/components/app-core/index.css',
],
nitro: {
preset: 'cloudflare_pages',
prerender: {
crawlLinks: true,
routes: [`/${defaultLanguage}/`],
concurrency: 35, // stay below 40 to avoid rate limiting
interval: 1000, // use 1 second interval to avoid rate limiting
failOnError: false,
},
routeRules: {
'/': { prerender: false },
'/*/blog/': { prerender: false },
'/blog-feed.xml': {
redirect: { to: '/blog/feed.json', statusCode: 301 },
},
'/mogelijk/api/event': {
proxy: { to: 'https://plausible.io/api/event' },
},
},
},
runtimeConfig: {
public: {
datoApiToken: process.env.DATOCMS_API_READ_TOKEN,
baseUrl: process.env.BASE_URL,
previewSecret: process.env.PREVIEW_SECRET,
},
},
modules: [
nuxtIcons,
plausible,
],
plausible: {
apiHost: '/mogelijk',
},
hooks: {
'build:before': () =>
Promise.all([
fetchTranslations()
.then(async (translations) => {
await mkdir('.cache', { recursive: true });
await writeFile(
'.cache/ui-translations.json',
JSON.stringify(translations),
);
}),
fetchBlogFeed()
.then(async (blogFeed) => {
await mkdir('./src/public/blog', { recursive: true });
await writeFile(
'./src/public/blog/feed.json',
JSON.stringify(blogFeed),
);
}),
fetchRedirects()
.then((redirects) => writeFile('./src/public/_redirects', redirects)),
fetchI18nSlugs()
.then(async (data) => {
await mkdir('.cache', { recursive: true });
await writeFile('.cache/i18n-slugs.json', JSON.stringify(data));
}),
])
// hook expects a promise with no return data
.then(() => {}),
},
});