* Fix ineffective option, fixed #10

* Feat: dropdown list, #6

* Fix repo url

* Feat: sidebar with toggle

* Update doc
This commit is contained in:
cinwell.li 2016-11-29 21:42:48 +08:00 committed by GitHub
commit d07ddaa85d
12 changed files with 380 additions and 24 deletions

View file

@ -6,6 +6,7 @@ const OPTIONS = {
repo: '',
maxLevel: 6,
sidebar: '',
sidebarToggle: false,
loadSidebar: null,
loadNavbar: null
}
@ -15,7 +16,7 @@ const script = document.currentScript || [].slice.call(document.getElementsByTag
if (script) {
for (const prop in OPTIONS) {
const val = script.getAttribute('data-' + camel2kebab(prop))
OPTIONS[prop] = isNil(val) ? OPTIONS[prop] : true
OPTIONS[prop] = isNil(val) ? OPTIONS[prop] : (val || true)
}
if (OPTIONS.loadSidebar === true) OPTIONS.loadSidebar = '_sidebar.md'
if (OPTIONS.loadNavbar === true) OPTIONS.loadNavbar = '_navbar.md'
@ -34,7 +35,8 @@ const Docsify = function () {
// Render markdown file
load(`${loc}.md`)
.then(render.renderArticle, _ => render.renderArticle())
.then(content => render.renderArticle(content, OPTIONS),
_ => render.renderArticle(null, OPTIONS))
// Render sidebar
if (OPTIONS.loadSidebar) {