forked from docsifyjs/docsify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
108 lines (93 loc) · 2.43 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
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
import stripIndent from 'strip-indent';
import { hyphenate, isPrimitive } from './util/core.js';
const currentScript = document.currentScript;
/** @param {import('./Docsify.js').Docsify} vm */
export default function (vm) {
const config = Object.assign(
{
auto2top: false,
autoHeader: false,
basePath: '',
catchPluginErrors: true,
cornerExternalLinkTarget: '_blank',
coverpage: '',
el: '#app',
executeScript: null,
ext: '.md',
externalLinkRel: 'noopener',
externalLinkTarget: '_blank',
formatUpdated: '',
ga: '',
homepage: 'README.md',
loadNavbar: null,
loadSidebar: null,
maxLevel: 6,
mergeNavbar: false,
name: '',
nameLink: window.location.pathname,
nativeEmoji: false,
noCompileLinks: [],
noEmoji: false,
notFoundPage: true,
plugins: [],
relativePath: false,
repo: '',
routes: {},
routerMode: 'hash',
subMaxLevel: 0,
// themeColor: '',
topMargin: 0,
// Deprecations //////////////////
__themeColor: '',
get themeColor() {
return this.__themeColor;
},
set themeColor(value) {
this.__themeColor = value;
console.warn(
stripIndent(/* html */ `
$docsify.themeColor is deprecated. Use a --theme-color property in your style sheet. Example:
<style>
:root {
--theme-color: deeppink;
}
</style>
`).trim()
);
},
},
typeof window.$docsify === 'function'
? window.$docsify(vm)
: window.$docsify
);
const script =
currentScript ||
Array.from(document.getElementsByTagName('script')).filter(n =>
/docsify\./.test(n.src)
)[0];
if (script) {
for (const prop of Object.keys(config)) {
const val = script.getAttribute('data-' + hyphenate(prop));
if (isPrimitive(val)) {
config[prop] = val === '' ? true : val;
}
}
}
if (config.loadSidebar === true) {
config.loadSidebar = '_sidebar' + config.ext;
}
if (config.loadNavbar === true) {
config.loadNavbar = '_navbar' + config.ext;
}
if (config.coverpage === true) {
config.coverpage = '_coverpage' + config.ext;
}
if (config.repo === true) {
config.repo = '';
}
if (config.name === true) {
config.name = '';
}
window.$docsify = config;
return config;
}