forked from BeamMW/beam-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.ts
204 lines (195 loc) · 4.79 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
// https://nuxt.com/docs/api/configuration/nuxt-config
import { join, sep } from "path";
import { globSync } from "glob";
import { pathExists, copy } from "fs-extra";
import { 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,
modules: [
"@nuxtjs/tailwindcss",
"@nuxtjs/i18n",
"@nuxtjs/device",
"nuxt-simple-sitemap",
"nuxt-simple-robots",
"@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,
},
},
nitro: {
prerender: {
routes: ["/sitemap.xml", ...docsRoutes],
// crawlLinks: true,
failOnError: false,
},
},
hooks: {
"build:before": async () => {
await copyDocsAssetsToPublic();
},
},
runtimeConfig: {
public: {
siteUrl: publicWebUrl,
baseURL: publicWebUrl,
},
},
content: {
documentDriven: false,
},
sitemap: {
discoverImages: false,
siteUrl: publicWebUrl,
},
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: "/ダウンロード",
},
"privacy-policy": {
en: "/privacy-policy",
fr: "/politique-de-confidentialite",
zh: "/隐私政策",
jp: "/プライバシーポリシー",
},
mining: {
en: "/mining",
fr: "/minage",
zh: "/挖矿",
jp: "/マイニング",
},
},
locales,
},
});