-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: async install config, fixed #425
- Loading branch information
1 parent
ef1b42b
commit e4e011c
Showing
2 changed files
with
60 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,70 @@ | ||
import {merge, hyphenate, isPrimitive, hasOwn} 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, | ||
autoHeader: false, | ||
executeScript: null, | ||
noEmoji: false, | ||
ga: '', | ||
ext: '.md', | ||
mergeNavbar: false, | ||
formatUpdated: '', | ||
externalLinkTarget: '_blank', | ||
routerMode: 'hash', | ||
noCompileLinks: [] | ||
}, | ||
window.$docsify | ||
) | ||
export default function () { | ||
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, | ||
autoHeader: false, | ||
executeScript: null, | ||
noEmoji: false, | ||
ga: '', | ||
ext: '.md', | ||
mergeNavbar: false, | ||
formatUpdated: '', | ||
externalLinkTarget: '_blank', | ||
routerMode: 'hash', | ||
noCompileLinks: [] | ||
}, | ||
window.$docsify | ||
) | ||
|
||
const script = | ||
document.currentScript || | ||
[].slice | ||
.call(document.getElementsByTagName('script')) | ||
.filter(n => /docsify\./.test(n.src))[0] | ||
const script = | ||
document.currentScript || | ||
[].slice | ||
.call(document.getElementsByTagName('script')) | ||
.filter(n => /docsify\./.test(n.src))[0] | ||
|
||
if (script) { | ||
for (const prop in config) { | ||
if (hasOwn.call(config, prop)) { | ||
const val = script.getAttribute('data-' + hyphenate(prop)) | ||
if (script) { | ||
for (const prop in config) { | ||
if (hasOwn.call(config, prop)) { | ||
const val = script.getAttribute('data-' + hyphenate(prop)) | ||
|
||
if (isPrimitive(val)) { | ||
config[prop] = val === '' ? true : val | ||
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 = '' | ||
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 | ||
window.$docsify = config | ||
|
||
export default config | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters