/
next.config.js
executable file
·49 lines (44 loc) · 1.36 KB
/
next.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
const config = require("./src/config/config.json");
const languages = require("./src/config/language.json");
const disableLanguages = config.settings.disable_languages;
const activeLanguages = languages.filter(
(lang) => !disableLanguages.includes(lang.languageCode),
);
const defaultLanguage = config.settings.default_language;
const otherLanguages = activeLanguages
.map((lang) => lang.languageCode)
.filter((lang) => lang !== defaultLanguage);
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
basePath: config.base_path !== "/" ? config.base_path : "",
trailingSlash: config.site.trailing_slash,
output: "standalone",
async rewrites() {
if (config.settings.default_language_in_subdir) {
return [];
}
return activeLanguages.length !== 1
? [
{
source: `/:lang(!${defaultLanguage}|${otherLanguages.join("|")})/:path*`,
destination: `/:lang/:path*`,
},
{
source: `/:path*`,
destination: `/${defaultLanguage}/:path*`,
},
]
: [
{
source: `/${defaultLanguage}/:path*`,
destination: `/${defaultLanguage}/:path*`,
},
{
source: "/:path*",
destination: `/${defaultLanguage}/:path*`,
},
];
},
};
module.exports = nextConfig;