-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
67 lines (59 loc) · 2.32 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const path = require('path')
const fs = require('fs')
let configJson = {}
let packageJson = {}
if (fs.existsSync('./website-generator-repo.json')) {
const clientConfigJson = require('./website-generator-repo.json')
configJson = require('./website-generator.json')
configJson = {
...clientConfigJson,
// override user configurable paths for build
outPath: configJson.outPath,
miscellaneousPages: clientConfigJson.miscellaneousPages ? configJson.miscellaneousPages : null,
codeDocs: clientConfigJson.codeDocs ? configJson.codeDocs : null,
}
packageJson = require('./package-repo.json')
} else {
configJson = require('./website-generator.json')
packageJson = require('./package.json')
}
const getSoeTags = () => {
if (configJson.soeTags && configJson.soeTags.length > 0) return configJson.soeTags.reduce((acc, cur) => acc + ' ' + cur)
if (packageJson.keywords && packageJson.keywords.length > 0) return packageJson.keywords.reduce((acc, cur) => acc + ' ' + cur)
return []
}
const getAttribution = () => {
return JSON.stringify(configJson.attribution ? configJson.attribution : [])
}
const getBasePath = () => {
if (process.env.CI) {
return process.env.GITHUB_REPOSITORY.includes('/')
? process.env.GITHUB_REPOSITORY.substring(process.env.GITHUB_REPOSITORY.indexOf('/'))
: '/' + process.env.GITHUB_REPOSITORY
}
return null
}
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
basePath: getBasePath(),
// Nothing fancy can be done here because of webpack
env: {
getReadmeFileName: configJson.readmeFileName,
genTitle: configJson.title,
genTitleSuperscript: configJson.titleSuperscript,
genName: configJson.name ?? packageJson.name,
genDescription: configJson.description ?? packageJson.description,
genGitHubUrl: configJson.gitHubUrl ?? packageJson.homepage,
genAuthor: configJson.author ?? packageJson.author,
genSEOTags: getSoeTags(),
genRootPath: configJson.rootPath,
genCodeDocs: configJson.codeDocs ? 'yes' : 'none',
genMiscellaneousPages: configJson.miscellaneousPages ? 'yes' : 'none',
genThemeIconLogo: configJson.theme.iconLogo,
genThemeImageLogo: configJson.theme.imageLogo,
genThemeImageLogoLink: configJson.theme.imageLogoLink,
genAttribution: getAttribution()
},
}
module.exports = nextConfig