-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathconfig.js
More file actions
54 lines (39 loc) · 1.36 KB
/
config.js
File metadata and controls
54 lines (39 loc) · 1.36 KB
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
/*!
* This source file is part of the open source project
* ExpressionEngine User Guide (https://github.com/ExpressionEngine/ExpressionEngine-User-Guide)
*
* @link https://expressionengine.com/
* @copyright Copyright (c) 2003-2019, EllisLab, Inc. (https://ellislab.com)
* @license https://expressionengine.com/license Licensed under Apache License, Version 2.0
*/
const fs = require('fs')
const path = require('path')
const yaml = require('js-yaml')
// -------------------------------------------------------------------
const DEFAULT_CONFIG = {
title: 'Site',
sourceDir: 'site',
outputDir: 'build',
customVariables: {},
tocPath: 'docs/_toc.yml',
pageTemplatePath: './theme/doc-page-template.html',
assetsDir: './theme/_assets',
assetsSourceDir: './theme/assets-src'
}
// -------------------------------------------------------------------
function getConfig() {
let configPath = path.resolve('./config.yml')
let config = {}
try {
// Get the config file
config = fs.readFileSync(configPath, { encoding: 'utf8' })
// Convert the yaml to json
config = yaml.safeLoad(config)
} catch (e) {
throw `Error loading config.yml: \n ${e}`
}
// Replace any missing config options with the defaults
return { ...DEFAULT_CONFIG, ...config }
}
// -------------------------------------------------------------------
module.exports = getConfig()