Skip to content

Commit

Permalink
fix config initialization and coercion (#861)
Browse files Browse the repository at this point in the history
* fix: document.currentScript reference

* fix: merge config
  • Loading branch information
L3au authored Feb 13, 2020
1 parent d798a12 commit 0e4cdad
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/core/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {merge, hyphenate, isPrimitive, hasOwn} from './util/core'

const currentScript = document.currentScript

export default function () {
const config = merge(
{
Expand Down Expand Up @@ -36,7 +38,7 @@ export default function () {
)

const script =
document.currentScript ||
currentScript ||
[].slice
.call(document.getElementsByTagName('script'))
.filter(n => /docsify\./.test(n.src))[0]
Expand All @@ -51,26 +53,22 @@ export default function () {
}
}
}
}

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 = ''
}
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
Expand Down

0 comments on commit 0e4cdad

Please sign in to comment.