-
Notifications
You must be signed in to change notification settings - Fork 216
/
Copy pathconfig.js
73 lines (66 loc) · 2.09 KB
/
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
68
69
70
71
72
73
// This file is generated from FairwindsOps/documentation-template
// DO NOT EDIT MANUALLY
const fs = require('fs');
const npath = require('path');
const CONFIG_FILE = npath.join(__dirname, 'config-extras.js');
const BASE_DIR = npath.join(__dirname, '..');
const extras = require(CONFIG_FILE);
if (!extras.title || !extras.description || !extras.themeConfig.docsRepo) {
throw new Error("Please specify 'title', 'description', and 'themeConfig.docsRepo' in config-extras.js");
}
const docFiles = fs.readdirSync(BASE_DIR)
.filter(f => f !== "README.md")
.filter(f => f !== ".vuepress")
.filter(f => f !== "node_modules")
.filter(f => npath.extname(f) === '.md' || npath.extname(f) === '');
const sidebar = [['/', 'Home']].concat(docFiles.map(f => {
const ext = npath.extname(f);
if (ext === '') {
// this is a directory
const title = f;
const children = fs.readdirSync(npath.join(BASE_DIR, f)).map(subf => {
return '/' + f + '/' + npath.basename(subf);
});
return {title, children};
}
const path = npath.basename(f);
return path;
}));
const baseConfig = {
title: "",
description: "",
head: [
['link', { rel: 'icon', href: '/favicon.png' }],
['script', { src: '/scripts/modify.js' }],
['script', { src: '/scripts/marketing.js' }],
],
themeConfig: {
docsRepo: "",
docsDir: 'docs',
editLinks: true,
editLinkText: "Help us improve this page",
logo: '/img/fairwinds-logo.svg',
heroText: "",
sidebar,
nav: [
{text: 'View on GitHub', link: 'https://github.com/' + extras.themeConfig.docsRepo},
],
},
plugins: {
'vuepress-plugin-clean-urls': {
normalSuffix: '/',
notFoundPath: '/404.html',
},
'check-md': {},
},
}
let config = JSON.parse(JSON.stringify(baseConfig))
if (!fs.existsSync(CONFIG_FILE)) {
throw new Error("Please add config-extras.js to specify your project details");
}
for (let key in extras) {
if (!config[key]) config[key] = extras[key];
else if (key === 'head') config[key] = config[key].concat(extras[key]);
else Object.assign(config[key], extras[key]);
}
module.exports = config;