[build] 4.0.0 next

This commit is contained in:
qingwei.li 2017-05-30 04:39:43 +08:00
commit b9b9d87681
No known key found for this signature in database
GPG key ID: B6DDC2F7AE80B2F4
8 changed files with 774 additions and 614 deletions

View file

@ -18,18 +18,18 @@ function escapeHtml (string) {
return String(string).replace(/[&<>"'\/]/g, function (s) { return entityMap[s]; })
}
function getAllPaths () {
function getAllPaths (router) {
var paths = [];
helper.dom.findAll('a:not([data-nosearch])')
.map(function (node) {
var href = node.href;
var originHref = node.getAttribute('href');
var path = helper.route.parse(href).path;
var path = router.parse(href).path;
if (path &&
paths.indexOf(path) === -1 &&
!helper.route.isAbsolutePath(originHref)) {
!Docsify.util.isAbsolutePath(originHref)) {
paths.push(path);
}
});
@ -42,12 +42,12 @@ function saveData (maxAge) {
localStorage.setItem('docsify.search.index', JSON.stringify(INDEXS));
}
function genIndex (path, content) {
function genIndex (path, content, router) {
if ( content === void 0 ) content = '';
var tokens = window.marked.lexer(content);
var slugify = window.Docsify.slugify;
var toURL = Docsify.route.toURL;
var toURL = router.toURL;
var index = {};
var slug;
@ -153,7 +153,7 @@ function init$1 (config, vm) {
return
}
var paths = isAuto ? getAllPaths() : config.paths;
var paths = isAuto ? getAllPaths(vm.router) : config.paths;
var len = paths.length;
var count = 0;
@ -161,9 +161,9 @@ function init$1 (config, vm) {
if (INDEXS[path]) { return count++ }
helper
.get(vm.$getFile(path))
.get(vm.router.getFile(path))
.then(function (result) {
INDEXS[path] = genIndex(path, result);
INDEXS[path] = genIndex(path, result, vm.router);
len === ++count && saveData(config.maxAge);
});
});
@ -246,9 +246,9 @@ function updateNoData (text, path) {
}
}
function init$$1 (opts) {
function init$$1 (opts, vm) {
dom = Docsify.dom;
var keywords = Docsify.route.parse().query.s;
var keywords = vm.router.parse().query.s;
style();
tpl(opts, keywords);
@ -284,7 +284,7 @@ var install = function (hook, vm) {
var isAuto = CONFIG.paths === 'auto';
hook.mounted(function (_) {
init$$1(CONFIG);
init$$1(CONFIG, vm);
!isAuto && init$1(CONFIG, vm);
});
hook.doneEach(function (_) {
@ -293,6 +293,6 @@ var install = function (hook, vm) {
});
};
window.$docsify.plugins = [].concat(install, window.$docsify.plugins);
$docsify.plugins = [].concat(install, $docsify.plugins);
}());