Skip to content

Commit 0e4cdad

Browse files
authored
fix config initialization and coercion (#861)
* fix: document.currentScript reference * fix: merge config
1 parent d798a12 commit 0e4cdad

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

Diff for: src/core/config.js

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {merge, hyphenate, isPrimitive, hasOwn} from './util/core'
22

3+
const currentScript = document.currentScript
4+
35
export default function () {
46
const config = merge(
57
{
@@ -36,7 +38,7 @@ export default function () {
3638
)
3739

3840
const script =
39-
document.currentScript ||
41+
currentScript ||
4042
[].slice
4143
.call(document.getElementsByTagName('script'))
4244
.filter(n => /docsify\./.test(n.src))[0]
@@ -51,26 +53,22 @@ export default function () {
5153
}
5254
}
5355
}
56+
}
5457

55-
if (config.loadSidebar === true) {
56-
config.loadSidebar = '_sidebar' + config.ext
57-
}
58-
59-
if (config.loadNavbar === true) {
60-
config.loadNavbar = '_navbar' + config.ext
61-
}
62-
63-
if (config.coverpage === true) {
64-
config.coverpage = '_coverpage' + config.ext
65-
}
66-
67-
if (config.repo === true) {
68-
config.repo = ''
69-
}
70-
71-
if (config.name === true) {
72-
config.name = ''
73-
}
58+
if (config.loadSidebar === true) {
59+
config.loadSidebar = '_sidebar' + config.ext
60+
}
61+
if (config.loadNavbar === true) {
62+
config.loadNavbar = '_navbar' + config.ext
63+
}
64+
if (config.coverpage === true) {
65+
config.coverpage = '_coverpage' + config.ext
66+
}
67+
if (config.repo === true) {
68+
config.repo = ''
69+
}
70+
if (config.name === true) {
71+
config.name = ''
7472
}
7573

7674
window.$docsify = config

0 commit comments

Comments
 (0)