refactor(core): adjust directory structure:

This commit is contained in:
qingwei.li 2017-02-16 23:37:39 +08:00 • committed by cinwell.li
commit aad62b65f5
20 changed files with 381 additions and 93 deletions

38
src/core/config.js Normal file
View file

@ -0,0 +1,38 @@
import { merge, camelize, isPrimitive } from './util/core'
const config = merge({
el: '#app',
repo: '',
maxLevel: 6,
subMaxLevel: 0,
loadSidebar: null,
loadNavbar: null,
homepage: 'README.md',
coverpage: '',
basePath: '',
auto2top: false,
name: '',
themeColor: '',
nameLink: window.location.pathname,
ga: ''
}, window.$docsify)
const script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop()
if (script) {
for (const prop in config) {
const val = script.getAttribute('data-' + camelize(prop))
if (isPrimitive(val)) {
config[prop] = val === '' ? true : val
}
}
if (config.loadSidebar === true) config.loadSidebar = '_sidebar.md'
if (config.loadNavbar === true) config.loadNavbar = '_navbar.md'
if (config.coverpage === true) config.coverpage = '_coverpage.md'
if (config.repo === true) config.repo = ''
if (config.name === true) config.name = ''
}
export default config