[build] 4.6.5
This commit is contained in:
parent
8352a1e489
commit
75222209da
19 changed files with 2763 additions and 298 deletions
|
|
@ -1,6 +1,6 @@
|
||||||

|

|
||||||
|
|
||||||
# docsify <small>4.6.4</small>
|
# docsify <small>4.6.5</small>
|
||||||
|
|
||||||
> A magical documentation site generator.
|
> A magical documentation site generator.
|
||||||
|
|
||||||
|
|
|
||||||
450
lib/docsify.js
450
lib/docsify.js
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
function cached(fn) {
|
function cached(fn) {
|
||||||
var cache = Object.create(null);
|
var cache = Object.create(null);
|
||||||
return function cachedFn (str) {
|
return function (str) {
|
||||||
var key = isPrimitive(str) ? str : JSON.stringify(str);
|
var key = isPrimitive(str) ? str : JSON.stringify(str);
|
||||||
var hit = cache[key];
|
var hit = cache[key];
|
||||||
return hit || (cache[key] = fn(str))
|
return hit || (cache[key] = fn(str))
|
||||||
|
|
@ -18,6 +18,8 @@ var hyphenate = cached(function (str) {
|
||||||
return str.replace(/([A-Z])/g, function (m) { return '-' + m.toLowerCase(); })
|
return str.replace(/([A-Z])/g, function (m) { return '-' + m.toLowerCase(); })
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var hasOwn = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple Object.assign polyfill
|
* Simple Object.assign polyfill
|
||||||
*/
|
*/
|
||||||
|
|
@ -26,8 +28,6 @@ var merge =
|
||||||
function (to) {
|
function (to) {
|
||||||
var arguments$1 = arguments;
|
var arguments$1 = arguments;
|
||||||
|
|
||||||
var hasOwn = Object.prototype.hasOwnProperty;
|
|
||||||
|
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
for (var i = 1; i < arguments.length; i++) {
|
||||||
var from = Object(arguments$1[i]);
|
var from = Object(arguments$1[i]);
|
||||||
|
|
||||||
|
|
@ -97,18 +97,30 @@ var script =
|
||||||
|
|
||||||
if (script) {
|
if (script) {
|
||||||
for (var prop in config) {
|
for (var prop in config) {
|
||||||
|
if (hasOwn.call(config, prop)) {
|
||||||
var val = script.getAttribute('data-' + hyphenate(prop));
|
var val = script.getAttribute('data-' + hyphenate(prop));
|
||||||
|
|
||||||
if (isPrimitive(val)) {
|
if (isPrimitive(val)) {
|
||||||
config[prop] = val === '' ? true : val;
|
config[prop] = val === '' ? true : val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (config.loadSidebar === true) { config.loadSidebar = '_sidebar' + config.ext; }
|
if (config.loadSidebar === true) {
|
||||||
if (config.loadNavbar === true) { config.loadNavbar = '_navbar' + config.ext; }
|
config.loadSidebar = '_sidebar' + config.ext;
|
||||||
if (config.coverpage === true) { config.coverpage = '_coverpage' + config.ext; }
|
}
|
||||||
if (config.repo === true) { config.repo = ''; }
|
if (config.loadNavbar === true) {
|
||||||
if (config.name === true) { config.name = ''; }
|
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;
|
||||||
|
|
@ -140,8 +152,7 @@ function callHook (vm, hook, data, next) {
|
||||||
var hook = queue[index];
|
var hook = queue[index];
|
||||||
if (index >= queue.length) {
|
if (index >= queue.length) {
|
||||||
next(data);
|
next(data);
|
||||||
} else {
|
} else if (typeof hook === 'function') {
|
||||||
if (typeof hook === 'function') {
|
|
||||||
if (hook.length === 2) {
|
if (hook.length === 2) {
|
||||||
hook(data, function (result) {
|
hook(data, function (result) {
|
||||||
data = result;
|
data = result;
|
||||||
|
|
@ -149,13 +160,12 @@ function callHook (vm, hook, data, next) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var result = hook(data);
|
var result = hook(data);
|
||||||
data = result !== undefined ? result : data;
|
data = result === undefined ? data : result;
|
||||||
step(index + 1);
|
step(index + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
step(index + 1);
|
step(index + 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
step(0);
|
step(0);
|
||||||
|
|
@ -176,7 +186,7 @@ var supportsPushState =
|
||||||
window.history &&
|
window.history &&
|
||||||
window.history.pushState &&
|
window.history.pushState &&
|
||||||
window.history.replaceState &&
|
window.history.replaceState &&
|
||||||
// pushState isn’t reliable on iOS until 5.
|
// PushState isn’t reliable on iOS until 5.
|
||||||
!navigator.userAgent.match(
|
!navigator.userAgent.match(
|
||||||
/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/
|
/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/
|
||||||
)
|
)
|
||||||
|
|
@ -234,7 +244,9 @@ function findAll (el, node) {
|
||||||
|
|
||||||
function create(node, tpl) {
|
function create(node, tpl) {
|
||||||
node = $.createElement(node);
|
node = $.createElement(node);
|
||||||
if (tpl) { node.innerHTML = tpl; }
|
if (tpl) {
|
||||||
|
node.innerHTML = tpl;
|
||||||
|
}
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,15 +259,15 @@ function before (target, el) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function on(el, type, handler) {
|
function on(el, type, handler) {
|
||||||
isFn(type)
|
isFn(type) ?
|
||||||
? window.addEventListener(el, type)
|
window.addEventListener(el, type) :
|
||||||
: el.addEventListener(type, handler);
|
el.addEventListener(type, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function off(el, type, handler) {
|
function off(el, type, handler) {
|
||||||
isFn(type)
|
isFn(type) ?
|
||||||
? window.removeEventListener(el, type)
|
window.removeEventListener(el, type) :
|
||||||
: el.removeEventListener(type, handler);
|
el.removeEventListener(type, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -296,8 +308,12 @@ var dom = Object.freeze({
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
function corner(data) {
|
function corner(data) {
|
||||||
if (!data) { return '' }
|
if (!data) {
|
||||||
if (!/\/\//.test(data)) { data = 'https://github.com/' + data; }
|
return ''
|
||||||
|
}
|
||||||
|
if (!/\/\//.test(data)) {
|
||||||
|
data = 'https://github.com/' + data;
|
||||||
|
}
|
||||||
data = data.replace(/^git\+/, '');
|
data = data.replace(/^git\+/, '');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -322,9 +338,9 @@ function main (config) {
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</button>' +
|
'</button>' +
|
||||||
'<aside class="sidebar">' +
|
'<aside class="sidebar">' +
|
||||||
(config.name
|
(config.name ?
|
||||||
? ("<h1><a class=\"app-name-link\" data-nosearch>" + (config.name) + "</a></h1>")
|
("<h1><a class=\"app-name-link\" data-nosearch>" + (config.name) + "</a></h1>") :
|
||||||
: '') +
|
'') +
|
||||||
'<div class="sidebar-nav"><!--sidebar--></div>' +
|
'<div class="sidebar-nav"><!--sidebar--></div>' +
|
||||||
'</aside>';
|
'</aside>';
|
||||||
|
|
||||||
|
|
@ -364,7 +380,9 @@ function cover () {
|
||||||
function tree(toc, tpl) {
|
function tree(toc, tpl) {
|
||||||
if ( tpl === void 0 ) tpl = '';
|
if ( tpl === void 0 ) tpl = '';
|
||||||
|
|
||||||
if (!toc || !toc.length) { return '' }
|
if (!toc || !toc.length) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
toc.forEach(function (node) {
|
toc.forEach(function (node) {
|
||||||
tpl += "<li><a class=\"section-link\" href=\"" + (node.slug) + "\">" + (node.title) + "</a></li>";
|
tpl += "<li><a class=\"section-link\" href=\"" + (node.slug) + "\">" + (node.title) + "</a></li>";
|
||||||
|
|
@ -452,8 +470,10 @@ function get (url, hasBar, headers) {
|
||||||
|
|
||||||
xhr.open('GET', url);
|
xhr.open('GET', url);
|
||||||
for (var i in headers) {
|
for (var i in headers) {
|
||||||
|
if (hasOwn.call(headers, i)) {
|
||||||
xhr.setRequestHeader(i, headers[i]);
|
xhr.setRequestHeader(i, headers[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
xhr.send();
|
xhr.send();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -506,15 +526,20 @@ function replaceVar (block, color) {
|
||||||
|
|
||||||
function cssVars (color) {
|
function cssVars (color) {
|
||||||
// Variable support
|
// Variable support
|
||||||
if (window.CSS && window.CSS.supports && window.CSS.supports('(--v:red)')) { return }
|
if (window.CSS && window.CSS.supports && window.CSS.supports('(--v:red)')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var styleBlocks = findAll('style:not(.inserted),link');[].forEach.call(styleBlocks, function (block) {
|
var styleBlocks = findAll('style:not(.inserted),link');
|
||||||
|
[].forEach.call(styleBlocks, function (block) {
|
||||||
if (block.nodeName === 'STYLE') {
|
if (block.nodeName === 'STYLE') {
|
||||||
replaceVar(block, color);
|
replaceVar(block, color);
|
||||||
} else if (block.nodeName === 'LINK') {
|
} else if (block.nodeName === 'LINK') {
|
||||||
var href = block.getAttribute('href');
|
var href = block.getAttribute('href');
|
||||||
|
|
||||||
if (!/\.css$/.test(href)) { return }
|
if (!/\.css$/.test(href)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
get(href).then(function (res) {
|
get(href).then(function (res) {
|
||||||
var style$$1 = create('style', res);
|
var style$$1 = create('style', res);
|
||||||
|
|
@ -2741,7 +2766,7 @@ Prism.languages.js = Prism.languages.javascript;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gen toc tree
|
* Gen toc tree
|
||||||
* @link https://github.com/killercup/grock/blob/5280ae63e16c5739e9233d9009bc235ed7d79a50/styles/solarized/assets/js/behavior.coffee#L54-L81
|
* @link https://github.com/killercup/grock/blob/5280ae63e16c5739e9233d9009bc235ed7d79a50/styles/solarized/assets/js/behavior.coffee#L54-L81
|
||||||
* @param {Array} toc
|
* @param {Array} toc
|
||||||
* @param {Number} maxLevel
|
* @param {Number} maxLevel
|
||||||
|
|
@ -2755,7 +2780,9 @@ function genTree (toc, maxLevel) {
|
||||||
var level = headline.level || 1;
|
var level = headline.level || 1;
|
||||||
var len = level - 1;
|
var len = level - 1;
|
||||||
|
|
||||||
if (level > maxLevel) { return }
|
if (level > maxLevel) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (last[len]) {
|
if (last[len]) {
|
||||||
last[len].children = (last[len].children || []).concat(headline);
|
last[len].children = (last[len].children || []).concat(headline);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2768,14 +2795,16 @@ function genTree (toc, maxLevel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var cache$1 = {};
|
var cache$1 = {};
|
||||||
var re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g;
|
var re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g;
|
||||||
|
|
||||||
function lower(string) {
|
function lower(string) {
|
||||||
return string.toLowerCase()
|
return string.toLowerCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
function slugify(str) {
|
function slugify(str) {
|
||||||
if (typeof str !== 'string') { return '' }
|
if (typeof str !== 'string') {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
var slug = str
|
var slug = str
|
||||||
.trim()
|
.trim()
|
||||||
|
|
@ -2787,7 +2816,7 @@ function slugify (str) {
|
||||||
.replace(/^(\d)/, '_$1');
|
.replace(/^(\d)/, '_$1');
|
||||||
var count = cache$1[slug];
|
var count = cache$1[slug];
|
||||||
|
|
||||||
count = cache$1.hasOwnProperty(slug) ? count + 1 : 0;
|
count = hasOwn.call(cache$1, slug) ? count + 1 : 0;
|
||||||
cache$1[slug] = count;
|
cache$1[slug] = count;
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
|
|
@ -2840,38 +2869,40 @@ function stringifyQuery (obj, ignores) {
|
||||||
var qs = [];
|
var qs = [];
|
||||||
|
|
||||||
for (var key in obj) {
|
for (var key in obj) {
|
||||||
if (ignores.indexOf(key) > -1) { continue }
|
if (ignores.indexOf(key) > -1) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
qs.push(
|
qs.push(
|
||||||
obj[key]
|
obj[key] ?
|
||||||
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
|
((encode(key)) + "=" + (encode(obj[key]))).toLowerCase() :
|
||||||
: encode(key)
|
encode(key)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return qs.length ? ("?" + (qs.join('&'))) : ''
|
return qs.length ? ("?" + (qs.join('&'))) : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPath () {
|
|
||||||
var args = [], len = arguments.length;
|
|
||||||
while ( len-- ) args[ len ] = arguments[ len ];
|
|
||||||
|
|
||||||
return cleanPath(args.join('/'))
|
|
||||||
}
|
|
||||||
|
|
||||||
var isAbsolutePath = cached(function (path) {
|
var isAbsolutePath = cached(function (path) {
|
||||||
return /(:|(\/{2}))/g.test(path)
|
return /(:|(\/{2}))/g.test(path)
|
||||||
});
|
});
|
||||||
|
|
||||||
var getParentPath = cached(function (path) {
|
var getParentPath = cached(function (path) {
|
||||||
return /\/$/g.test(path)
|
return /\/$/g.test(path) ?
|
||||||
? path
|
path :
|
||||||
: (path = path.match(/(\S*\/)[^\/]+$/)) ? path[1] : ''
|
(path = path.match(/(\S*\/)[^/]+$/)) ? path[1] : ''
|
||||||
});
|
});
|
||||||
|
|
||||||
var cleanPath = cached(function (path) {
|
var cleanPath = cached(function (path) {
|
||||||
return path.replace(/^\/+/, '/').replace(/([^:])\/{2,}/g, '$1/')
|
return path.replace(/^\/+/, '/').replace(/([^:])\/{2,}/g, '$1/')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getPath() {
|
||||||
|
var args = [], len = arguments.length;
|
||||||
|
while ( len-- ) args[ len ] = arguments[ len ];
|
||||||
|
|
||||||
|
return cleanPath(args.join('/'))
|
||||||
|
}
|
||||||
|
|
||||||
var replaceSlug = cached(function (path) {
|
var replaceSlug = cached(function (path) {
|
||||||
return path.replace('#', '?id=')
|
return path.replace('#', '?id=')
|
||||||
});
|
});
|
||||||
|
|
@ -2920,7 +2951,9 @@ var compileMedia = {
|
||||||
var lang = url.match(/\.(\w+)$/);
|
var lang = url.match(/\.(\w+)$/);
|
||||||
|
|
||||||
lang = title || (lang && lang[1]);
|
lang = title || (lang && lang[1]);
|
||||||
if (lang === 'md') { lang = 'markdown'; }
|
if (lang === 'md') {
|
||||||
|
lang = 'markdown';
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: url,
|
url: url,
|
||||||
|
|
@ -2956,7 +2989,9 @@ var Compiler = function Compiler (config, router) {
|
||||||
this.compile = cached(function (text) {
|
this.compile = cached(function (text) {
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
||||||
if (!text) { return text }
|
if (!text) {
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
if (isPrimitive(text)) {
|
if (isPrimitive(text)) {
|
||||||
html = compile(text);
|
html = compile(text);
|
||||||
|
|
@ -3029,7 +3064,7 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||||
var origin = {};
|
var origin = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* render anchor tag
|
* Render anchor tag
|
||||||
* @link https://github.com/chjj/marked#overriding-renderer-methods
|
* @link https://github.com/chjj/marked#overriding-renderer-methods
|
||||||
*/
|
*/
|
||||||
origin.heading = renderer.heading = function (text, level) {
|
origin.heading = renderer.heading = function (text, level) {
|
||||||
|
|
@ -3054,7 +3089,7 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||||
|
|
||||||
return ("<h" + level + " id=\"" + slug + "\"><a href=\"" + url + "\" data-id=\"" + slug + "\" class=\"anchor\"><span>" + text + "</span></a></h" + level + ">")
|
return ("<h" + level + " id=\"" + slug + "\"><a href=\"" + url + "\" data-id=\"" + slug + "\" class=\"anchor\"><span>" + text + "</span></a></h" + level + ">")
|
||||||
};
|
};
|
||||||
// highlight code
|
// Highlight code
|
||||||
origin.code = renderer.code = function (code, lang) {
|
origin.code = renderer.code = function (code, lang) {
|
||||||
if ( lang === void 0 ) lang = '';
|
if ( lang === void 0 ) lang = '';
|
||||||
|
|
||||||
|
|
@ -3081,7 +3116,9 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||||
!_self._matchNotCompileLink(href) &&
|
!_self._matchNotCompileLink(href) &&
|
||||||
!config.ignore
|
!config.ignore
|
||||||
) {
|
) {
|
||||||
if (href === _self.config.homepage) { href = 'README'; }
|
if (href === _self.config.homepage) {
|
||||||
|
href = 'README';
|
||||||
|
}
|
||||||
href = router.toURL(href, null, router.getCurrentPath());
|
href = router.toURL(href, null, router.getCurrentPath());
|
||||||
} else {
|
} else {
|
||||||
attrs += " target=\"" + linkTarget + "\"";
|
attrs += " target=\"" + linkTarget + "\"";
|
||||||
|
|
@ -3103,12 +3140,15 @@ Compiler.prototype._initRenderer = function _initRenderer () {
|
||||||
return ("<a href=\"" + href + "\"" + attrs + ">" + text + "</a>")
|
return ("<a href=\"" + href + "\"" + attrs + ">" + text + "</a>")
|
||||||
};
|
};
|
||||||
origin.paragraph = renderer.paragraph = function (text) {
|
origin.paragraph = renderer.paragraph = function (text) {
|
||||||
|
var result;
|
||||||
if (/^!>/.test(text)) {
|
if (/^!>/.test(text)) {
|
||||||
return helper('tip', text)
|
result = helper('tip', text);
|
||||||
} else if (/^\?>/.test(text)) {
|
} else if (/^\?>/.test(text)) {
|
||||||
return helper('warn', text)
|
result = helper('warn', text);
|
||||||
|
} else {
|
||||||
|
result = "<p>" + text + "</p>";
|
||||||
}
|
}
|
||||||
return ("<p>" + text + "</p>")
|
return result
|
||||||
};
|
};
|
||||||
origin.image = renderer.image = function (href, title, text) {
|
origin.image = renderer.image = function (href, title, text) {
|
||||||
var url = href;
|
var url = href;
|
||||||
|
|
@ -3217,7 +3257,7 @@ var title = $.title;
|
||||||
/**
|
/**
|
||||||
* Toggle button
|
* Toggle button
|
||||||
*/
|
*/
|
||||||
function btn (el, router) {
|
function btn(el) {
|
||||||
var toggle = function (_) { return body.classList.toggle('close'); };
|
var toggle = function (_) { return body.classList.toggle('close'); };
|
||||||
|
|
||||||
el = getNode(el);
|
el = getNode(el);
|
||||||
|
|
@ -3234,7 +3274,7 @@ function btn (el, router) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function collapse (el, router) {
|
function collapse(el) {
|
||||||
el = getNode(el);
|
el = getNode(el);
|
||||||
|
|
||||||
on(el, 'click', function (ref) {
|
on(el, 'click', function (ref) {
|
||||||
|
|
@ -3252,7 +3292,9 @@ function collapse (el, router) {
|
||||||
|
|
||||||
function sticky() {
|
function sticky() {
|
||||||
var cover = getNode('section.cover');
|
var cover = getNode('section.cover');
|
||||||
if (!cover) { return }
|
if (!cover) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var coverHeight = cover.getBoundingClientRect().height;
|
var coverHeight = cover.getBoundingClientRect().height;
|
||||||
|
|
||||||
if (window.pageYOffset >= coverHeight || cover.classList.contains('hidden')) {
|
if (window.pageYOffset >= coverHeight || cover.classList.contains('hidden')) {
|
||||||
|
|
@ -3398,7 +3440,9 @@ var enableScrollEvent = true;
|
||||||
var coverHeight = 0;
|
var coverHeight = 0;
|
||||||
|
|
||||||
function scrollTo(el) {
|
function scrollTo(el) {
|
||||||
if (scroller) { scroller.stop(); }
|
if (scroller) {
|
||||||
|
scroller.stop();
|
||||||
|
}
|
||||||
enableScrollEvent = false;
|
enableScrollEvent = false;
|
||||||
scroller = new Tweezer({
|
scroller = new Tweezer({
|
||||||
start: window.pageYOffset,
|
start: window.pageYOffset,
|
||||||
|
|
@ -3414,7 +3458,9 @@ function scrollTo (el) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlight(path) {
|
function highlight(path) {
|
||||||
if (!enableScrollEvent) { return }
|
if (!enableScrollEvent) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var sidebar = getNode('.sidebar');
|
var sidebar = getNode('.sidebar');
|
||||||
var anchors = findAll('.anchor');
|
var anchors = findAll('.anchor');
|
||||||
var wrap = find(sidebar, '.sidebar-nav');
|
var wrap = find(sidebar, '.sidebar-nav');
|
||||||
|
|
@ -3427,22 +3473,28 @@ function highlight (path) {
|
||||||
var node = anchors[i];
|
var node = anchors[i];
|
||||||
|
|
||||||
if (node.offsetTop > top) {
|
if (node.offsetTop > top) {
|
||||||
if (!last) { last = node; }
|
if (!last) {
|
||||||
|
last = node;
|
||||||
|
}
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
last = node;
|
last = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!last) { return }
|
if (!last) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var li = nav[getNavKey(path, last.getAttribute('data-id'))];
|
var li = nav[getNavKey(path, last.getAttribute('data-id'))];
|
||||||
|
|
||||||
if (!li || li === active) { return }
|
if (!li || li === active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
active && active.classList.remove('active');
|
active && active.classList.remove('active');
|
||||||
li.classList.add('active');
|
li.classList.add('active');
|
||||||
active = li;
|
active = li;
|
||||||
|
|
||||||
// scroll into view
|
// Scroll into view
|
||||||
// https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297
|
// https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297
|
||||||
if (!hoverOver && body.classList.contains('sticky')) {
|
if (!hoverOver && body.classList.contains('sticky')) {
|
||||||
var height = sidebar.clientHeight;
|
var height = sidebar.clientHeight;
|
||||||
|
|
@ -3471,20 +3523,28 @@ function scrollActiveSidebar (router) {
|
||||||
for (var i = 0, len = lis.length; i < len; i += 1) {
|
for (var i = 0, len = lis.length; i < len; i += 1) {
|
||||||
var li = lis[i];
|
var li = lis[i];
|
||||||
var a = li.querySelector('a');
|
var a = li.querySelector('a');
|
||||||
if (!a) { continue }
|
if (!a) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
var href = a.getAttribute('href');
|
var href = a.getAttribute('href');
|
||||||
|
|
||||||
if (href !== '/') {
|
if (href !== '/') {
|
||||||
var ref = router.parse(href);
|
var ref = router.parse(href);
|
||||||
var id = ref.query.id;
|
var id = ref.query.id;
|
||||||
var path$1 = ref.path;
|
var path$1 = ref.path;
|
||||||
if (id) { href = getNavKey(path$1, id); }
|
if (id) {
|
||||||
|
href = getNavKey(path$1, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (href) { nav[decodeURIComponent(href)] = li; }
|
if (href) {
|
||||||
|
nav[decodeURIComponent(href)] = li;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMobile) { return }
|
if (isMobile) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var path = router.getCurrentPath();
|
var path = router.getCurrentPath();
|
||||||
off('scroll', function () { return highlight(path); });
|
off('scroll', function () { return highlight(path); });
|
||||||
on('scroll', function () { return highlight(path); });
|
on('scroll', function () { return highlight(path); });
|
||||||
|
|
@ -3497,7 +3557,9 @@ function scrollActiveSidebar (router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollIntoView(path, id) {
|
function scrollIntoView(path, id) {
|
||||||
if (!id) { return }
|
if (!id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var section = find('#' + id);
|
var section = find('#' + id);
|
||||||
section && scrollTo(section);
|
section && scrollTo(section);
|
||||||
|
|
@ -3619,9 +3681,13 @@ function prerenderEmbed (ref, done) {
|
||||||
function executeScript() {
|
function executeScript() {
|
||||||
var script = findAll('.markdown-section>script')
|
var script = findAll('.markdown-section>script')
|
||||||
.filter(function (s) { return !/template/.test(s.type); })[0];
|
.filter(function (s) { return !/template/.test(s.type); })[0];
|
||||||
if (!script) { return false }
|
if (!script) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
var code = script.innerText.trim();
|
var code = script.innerText.trim();
|
||||||
if (!code) { return false }
|
if (!code) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(function (_) {
|
setTimeout(function (_) {
|
||||||
window.__EXECUTE_RESULT__ = new Function(code)();
|
window.__EXECUTE_RESULT__ = new Function(code)();
|
||||||
|
|
@ -3630,24 +3696,23 @@ function executeScript () {
|
||||||
|
|
||||||
function formatUpdated(html, updated, fn) {
|
function formatUpdated(html, updated, fn) {
|
||||||
updated =
|
updated =
|
||||||
typeof fn === 'function'
|
typeof fn === 'function' ?
|
||||||
? fn(updated)
|
fn(updated) :
|
||||||
: typeof fn === 'string' ? tinydate(fn)(new Date(updated)) : updated;
|
typeof fn === 'string' ? tinydate(fn)(new Date(updated)) : updated;
|
||||||
|
|
||||||
return html.replace(/{docsify-updated}/g, updated)
|
return html.replace(/{docsify-updated}/g, updated)
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMain(html) {
|
function renderMain(html) {
|
||||||
if (!html) {
|
if (!html) {
|
||||||
// TODO: Custom 404 page
|
html = '<h1>404 - Not found</h1>';
|
||||||
html = 'not found';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._renderTo('.markdown-section', html);
|
this._renderTo('.markdown-section', html);
|
||||||
// Render sidebar with the TOC
|
// Render sidebar with the TOC
|
||||||
!this.config.loadSidebar && this._renderSidebar();
|
!this.config.loadSidebar && this._renderSidebar();
|
||||||
|
|
||||||
// execute script
|
// Execute script
|
||||||
if (
|
if (
|
||||||
this.config.executeScript !== false &&
|
this.config.executeScript !== false &&
|
||||||
typeof window.Vue !== 'undefined' &&
|
typeof window.Vue !== 'undefined' &&
|
||||||
|
|
@ -3668,7 +3733,9 @@ function renderNameLink (vm) {
|
||||||
var nameLink = vm.config.nameLink;
|
var nameLink = vm.config.nameLink;
|
||||||
var path = vm.route.path;
|
var path = vm.route.path;
|
||||||
|
|
||||||
if (!el) { return }
|
if (!el) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (isPrimitive(vm.config.nameLink)) {
|
if (isPrimitive(vm.config.nameLink)) {
|
||||||
el.setAttribute('href', nameLink);
|
el.setAttribute('href', nameLink);
|
||||||
|
|
@ -3682,7 +3749,9 @@ function renderNameLink (vm) {
|
||||||
function renderMixin(proto) {
|
function renderMixin(proto) {
|
||||||
proto._renderTo = function (el, content, replace) {
|
proto._renderTo = function (el, content, replace) {
|
||||||
var node = getNode(el);
|
var node = getNode(el);
|
||||||
if (node) { node[replace ? 'outerHTML' : 'innerHTML'] = content; }
|
if (node) {
|
||||||
|
node[replace ? 'outerHTML' : 'innerHTML'] = content;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
proto._renderSidebar = function (text) {
|
proto._renderSidebar = function (text) {
|
||||||
|
|
@ -3697,10 +3766,10 @@ function renderMixin (proto) {
|
||||||
activeEl.parentNode.innerHTML +=
|
activeEl.parentNode.innerHTML +=
|
||||||
this.compiler.subSidebar(subMaxLevel) || '';
|
this.compiler.subSidebar(subMaxLevel) || '';
|
||||||
} else {
|
} else {
|
||||||
// reset toc
|
// Reset toc
|
||||||
this.compiler.subSidebar();
|
this.compiler.subSidebar();
|
||||||
}
|
}
|
||||||
// bind event
|
// Bind event
|
||||||
this._bindEventOnRendered(activeEl);
|
this._bindEventOnRendered(activeEl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -3726,7 +3795,9 @@ function renderMixin (proto) {
|
||||||
|
|
||||||
proto._renderNav = function (text) {
|
proto._renderNav = function (text) {
|
||||||
text && this._renderTo('nav', this.compiler.compile(text));
|
text && this._renderTo('nav', this.compiler.compile(text));
|
||||||
|
if (this.config.loadNavbar) {
|
||||||
getAndActive(this.router, 'nav');
|
getAndActive(this.router, 'nav');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
proto._renderMain = function (text, opt, next) {
|
proto._renderMain = function (text, opt, next) {
|
||||||
|
|
@ -3803,7 +3874,7 @@ function renderMixin (proto) {
|
||||||
};
|
};
|
||||||
|
|
||||||
proto._updateRender = function () {
|
proto._updateRender = function () {
|
||||||
// render name link
|
// Render name link
|
||||||
renderNameLink(this);
|
renderNameLink(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -3814,7 +3885,7 @@ function initRender (vm) {
|
||||||
// Init markdown compiler
|
// Init markdown compiler
|
||||||
vm.compiler = new Compiler(config, vm.router);
|
vm.compiler = new Compiler(config, vm.router);
|
||||||
if (inBrowser) {
|
if (inBrowser) {
|
||||||
window['__current_docsify_compiler__'] = vm.compiler;
|
window.__current_docsify_compiler__ = vm.compiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
var id = config.el || '#app';
|
var id = config.el || '#app';
|
||||||
|
|
@ -3850,7 +3921,9 @@ function initRender (vm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add nav
|
// Add nav
|
||||||
|
if (config.loadNavbar) {
|
||||||
before(navAppendToTarget, navEl);
|
before(navAppendToTarget, navEl);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.themeColor) {
|
if (config.themeColor) {
|
||||||
$.head.appendChild(
|
$.head.appendChild(
|
||||||
|
|
@ -3871,15 +3944,15 @@ function getAlias (path, alias, last) {
|
||||||
return re.test(path) && path !== last
|
return re.test(path) && path !== last
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
return match
|
return match ?
|
||||||
? getAlias(path.replace(cached$2[match], alias[match]), alias, path)
|
getAlias(path.replace(cached$2[match], alias[match]), alias, path) :
|
||||||
: path
|
path
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFileName(path, ext) {
|
function getFileName(path, ext) {
|
||||||
return new RegExp(("\\.(" + (ext.replace(/^\./, '')) + "|html)$"), 'g').test(path)
|
return new RegExp(("\\.(" + (ext.replace(/^\./, '')) + "|html)$"), 'g').test(path) ?
|
||||||
? path
|
path :
|
||||||
: /\/$/g.test(path) ? (path + "README" + ext) : ("" + path + ext)
|
/\/$/g.test(path) ? (path + "README" + ext) : ("" + path + ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
var History = function History(config) {
|
var History = function History(config) {
|
||||||
|
|
@ -3896,7 +3969,7 @@ History.prototype.getFile = function getFile (path, isRelative) {
|
||||||
var ref = this;
|
var ref = this;
|
||||||
var config = ref.config;
|
var config = ref.config;
|
||||||
var base = this.getBasePath();
|
var base = this.getBasePath();
|
||||||
var ext = typeof config.ext !== 'string' ? '.md' : config.ext;
|
var ext = typeof config.ext === 'string' ? config.ext : '.md';
|
||||||
|
|
||||||
path = config.alias ? getAlias(path, config.alias) : path;
|
path = config.alias ? getAlias(path, config.alias) : path;
|
||||||
path = getFileName(path, ext);
|
path = getFileName(path, ext);
|
||||||
|
|
@ -3980,7 +4053,9 @@ var HashHistory = (function (History$$1) {
|
||||||
|
|
||||||
path = replaceSlug(path);
|
path = replaceSlug(path);
|
||||||
|
|
||||||
if (path.charAt(0) === '/') { return replaceHash(path) }
|
if (path.charAt(0) === '/') {
|
||||||
|
return replaceHash(path)
|
||||||
|
}
|
||||||
replaceHash('/' + path);
|
replaceHash('/' + path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -4134,7 +4209,10 @@ function initRouter (vm) {
|
||||||
function eventMixin(proto) {
|
function eventMixin(proto) {
|
||||||
proto.$resetEvents = function () {
|
proto.$resetEvents = function () {
|
||||||
scrollIntoView(this.route.path, this.route.query.id);
|
scrollIntoView(this.route.path, this.route.query.id);
|
||||||
|
|
||||||
|
if (this.config.loadNavbar) {
|
||||||
getAndActive(this.router, 'nav');
|
getAndActive(this.router, 'nav');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4154,7 +4232,9 @@ function loadNested (path, qs, file, next, vm, first) {
|
||||||
path = first ? path : path.replace(/\/$/, '');
|
path = first ? path : path.replace(/\/$/, '');
|
||||||
path = getParentPath(path);
|
path = getParentPath(path);
|
||||||
|
|
||||||
if (!path) { return }
|
if (!path) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
get(
|
get(
|
||||||
vm.router.getFile(path + file) + qs,
|
vm.router.getFile(path + file) + qs,
|
||||||
|
|
@ -4165,6 +4245,62 @@ function loadNested (path, qs, file, next, vm, first) {
|
||||||
|
|
||||||
function fetchMixin(proto) {
|
function fetchMixin(proto) {
|
||||||
var last;
|
var last;
|
||||||
|
|
||||||
|
var abort = function () { return last && last.abort && last.abort(); };
|
||||||
|
var request = function (url, hasbar, requestHeaders) {
|
||||||
|
abort();
|
||||||
|
last = get(url, true, requestHeaders);
|
||||||
|
return last
|
||||||
|
};
|
||||||
|
|
||||||
|
var get404Path = function (path, config) {
|
||||||
|
var notFoundPage = config.notFoundPage;
|
||||||
|
var ext = config.ext;
|
||||||
|
var defaultPath = '_404' + (ext || '.md');
|
||||||
|
var key;
|
||||||
|
var path404;
|
||||||
|
|
||||||
|
switch (typeof notFoundPage) {
|
||||||
|
case 'boolean':
|
||||||
|
path404 = defaultPath;
|
||||||
|
break
|
||||||
|
case 'string':
|
||||||
|
path404 = notFoundPage;
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'object':
|
||||||
|
key = Object.keys(notFoundPage)
|
||||||
|
.sort(function (a, b) { return b.length - a.length; })
|
||||||
|
.find(function (key) { return path.match(new RegExp('^' + key)); });
|
||||||
|
|
||||||
|
path404 = (key && notFoundPage[key]) || defaultPath;
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return path404
|
||||||
|
};
|
||||||
|
|
||||||
|
proto._loadSideAndNav = function (path, qs, loadSidebar, cb) {
|
||||||
|
var this$1 = this;
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
if (!loadSidebar) {
|
||||||
|
return cb()
|
||||||
|
}
|
||||||
|
|
||||||
|
var fn = function (result) {
|
||||||
|
this$1._renderSidebar(result);
|
||||||
|
cb();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Load sidebar
|
||||||
|
loadNested(path, qs, loadSidebar, fn, this$1, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
proto._fetch = function (cb) {
|
proto._fetch = function (cb) {
|
||||||
var this$1 = this;
|
var this$1 = this;
|
||||||
if ( cb === void 0 ) cb = noop;
|
if ( cb === void 0 ) cb = noop;
|
||||||
|
|
@ -4175,62 +4311,25 @@ function fetchMixin (proto) {
|
||||||
var qs = stringifyQuery(query, ['id']);
|
var qs = stringifyQuery(query, ['id']);
|
||||||
var ref$1 = this.config;
|
var ref$1 = this.config;
|
||||||
var loadNavbar = ref$1.loadNavbar;
|
var loadNavbar = ref$1.loadNavbar;
|
||||||
var loadSidebar = ref$1.loadSidebar;
|
|
||||||
var requestHeaders = ref$1.requestHeaders;
|
var requestHeaders = ref$1.requestHeaders;
|
||||||
var fallbackLanguages = ref$1.fallbackLanguages;
|
var loadSidebar = ref$1.loadSidebar;
|
||||||
// Abort last request
|
// Abort last request
|
||||||
last && last.abort && last.abort();
|
|
||||||
|
|
||||||
var file = this.router.getFile(path);
|
var file = this.router.getFile(path);
|
||||||
last = get(file + qs, true, requestHeaders);
|
var req = request(file + qs, true, requestHeaders);
|
||||||
|
|
||||||
// Current page is html
|
// Current page is html
|
||||||
this.isHTML = /\.html$/g.test(file);
|
this.isHTML = /\.html$/g.test(file);
|
||||||
|
|
||||||
var getFallBackPage = function (file) {
|
|
||||||
if (!fallbackLanguages) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
var local = file.split('/')[1];
|
|
||||||
|
|
||||||
if (fallbackLanguages.indexOf(local) === -1) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
file = file.replace(new RegExp(("^/" + local)), '');
|
|
||||||
|
|
||||||
return get(file + qs, true, requestHeaders)
|
|
||||||
.then(
|
|
||||||
function (text, opt) {
|
|
||||||
this$1._renderMain(text, opt, loadSideAndNav);
|
|
||||||
},
|
|
||||||
function (_) {
|
|
||||||
return this$1._renderMain(null, {}, loadSideAndNav)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
var loadSideAndNav = function () {
|
|
||||||
if (!loadSidebar) { return cb() }
|
|
||||||
|
|
||||||
var fn = function (result) {
|
|
||||||
this$1._renderSidebar(result);
|
|
||||||
cb();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Load sidebar
|
|
||||||
loadNested(path, qs, loadSidebar, fn, this$1, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Load main content
|
// Load main content
|
||||||
last
|
req.then(
|
||||||
.then(
|
function (text, opt) { return this$1._renderMain(
|
||||||
function (text, opt) {
|
text,
|
||||||
this$1._renderMain(text, opt, loadSideAndNav);
|
opt,
|
||||||
},
|
this$1._loadSideAndNav(path, qs, loadSidebar, cb)
|
||||||
|
); },
|
||||||
function (_) {
|
function (_) {
|
||||||
return getFallBackPage(file) || this$1._renderMain(null, {}, loadSideAndNav)
|
this$1._fetchFallbackPage(file, qs, cb) || this$1._fetch404(file, qs, cb);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -4269,7 +4368,7 @@ function fetchMixin (proto) {
|
||||||
path = cover === true ? '_coverpage' : cover;
|
path = cover === true ? '_coverpage' : cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
var coverOnly = !!path && this.config.onlyCover;
|
var coverOnly = Boolean(path) && this.config.onlyCover;
|
||||||
if (path) {
|
if (path) {
|
||||||
path = this.router.getFile(root + path);
|
path = this.router.getFile(root + path);
|
||||||
this.coverIsHTML = /\.html$/g.test(path);
|
this.coverIsHTML = /\.html$/g.test(path);
|
||||||
|
|
@ -4297,12 +4396,76 @@ function fetchMixin (proto) {
|
||||||
if (onlyCover) {
|
if (onlyCover) {
|
||||||
done();
|
done();
|
||||||
} else {
|
} else {
|
||||||
this._fetch(function (result) {
|
this._fetch(function () {
|
||||||
this$1.$resetEvents();
|
this$1.$resetEvents();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
proto._fetchFallbackPage = function (path, qs, cb) {
|
||||||
|
var this$1 = this;
|
||||||
|
if ( cb === void 0 ) cb = noop;
|
||||||
|
|
||||||
|
var ref = this.config;
|
||||||
|
var requestHeaders = ref.requestHeaders;
|
||||||
|
var fallbackLanguages = ref.fallbackLanguages;
|
||||||
|
var loadSidebar = ref.loadSidebar;
|
||||||
|
|
||||||
|
if (!fallbackLanguages) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var local = path.split('/')[1];
|
||||||
|
|
||||||
|
if (fallbackLanguages.indexOf(local) === -1) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var newPath = path.replace(new RegExp(("^/" + local)), '');
|
||||||
|
var req = request(newPath + qs, true, requestHeaders);
|
||||||
|
|
||||||
|
req.then(
|
||||||
|
function (text, opt) { return this$1._renderMain(
|
||||||
|
text,
|
||||||
|
opt,
|
||||||
|
this$1._loadSideAndNav(path, qs, loadSidebar, cb)
|
||||||
|
); },
|
||||||
|
function () { return this$1._fetch404(path, qs, cb); }
|
||||||
|
);
|
||||||
|
|
||||||
|
return true
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Load the 404 page
|
||||||
|
* @param path
|
||||||
|
* @param qs
|
||||||
|
* @param cb
|
||||||
|
* @returns {*}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
proto._fetch404 = function (path, qs, cb) {
|
||||||
|
var this$1 = this;
|
||||||
|
if ( cb === void 0 ) cb = noop;
|
||||||
|
|
||||||
|
var ref = this.config;
|
||||||
|
var loadSidebar = ref.loadSidebar;
|
||||||
|
var requestHeaders = ref.requestHeaders;
|
||||||
|
var notFoundPage = ref.notFoundPage;
|
||||||
|
|
||||||
|
var fnLoadSideAndNav = this._loadSideAndNav(path, qs, loadSidebar, cb);
|
||||||
|
if (notFoundPage) {
|
||||||
|
var path404 = get404Path(path, this.config);
|
||||||
|
|
||||||
|
request(this.router.getFile(path404), true, requestHeaders).then(
|
||||||
|
function (text, opt) { return this$1._renderMain(text, opt, fnLoadSideAndNav); },
|
||||||
|
function () { return this$1._renderMain(null, {}, fnLoadSideAndNav); }
|
||||||
|
);
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
this._renderMain(null, {}, fnLoadSideAndNav);
|
||||||
|
return false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function initFetch(vm) {
|
function initFetch(vm) {
|
||||||
|
|
@ -4349,6 +4512,7 @@ function initPlugin (vm) {
|
||||||
var util = Object.freeze({
|
var util = Object.freeze({
|
||||||
cached: cached,
|
cached: cached,
|
||||||
hyphenate: hyphenate,
|
hyphenate: hyphenate,
|
||||||
|
hasOwn: hasOwn,
|
||||||
merge: merge,
|
merge: merge,
|
||||||
isPrimitive: isPrimitive,
|
isPrimitive: isPrimitive,
|
||||||
noop: noop,
|
noop: noop,
|
||||||
|
|
@ -4358,10 +4522,10 @@ var util = Object.freeze({
|
||||||
supportsPushState: supportsPushState,
|
supportsPushState: supportsPushState,
|
||||||
parseQuery: parseQuery,
|
parseQuery: parseQuery,
|
||||||
stringifyQuery: stringifyQuery,
|
stringifyQuery: stringifyQuery,
|
||||||
getPath: getPath,
|
|
||||||
isAbsolutePath: isAbsolutePath,
|
isAbsolutePath: isAbsolutePath,
|
||||||
getParentPath: getParentPath,
|
getParentPath: getParentPath,
|
||||||
cleanPath: cleanPath,
|
cleanPath: cleanPath,
|
||||||
|
getPath: getPath,
|
||||||
replaceSlug: replaceSlug
|
replaceSlug: replaceSlug
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -4405,7 +4569,7 @@ initGlobalAPI();
|
||||||
/**
|
/**
|
||||||
* Version
|
* Version
|
||||||
*/
|
*/
|
||||||
Docsify.version = '4.6.4';
|
Docsify.version = '4.6.5';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run Docsify
|
* Run Docsify
|
||||||
|
|
|
||||||
2
lib/docsify.min.js
vendored
2
lib/docsify.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -16,7 +16,7 @@ function install (hook, vm) {
|
||||||
|
|
||||||
script.async = true;
|
script.async = true;
|
||||||
script.src = "https://" + disqus + ".disqus.com/embed.js";
|
script.src = "https://" + disqus + ".disqus.com/embed.js";
|
||||||
script.setAttribute('data-timestamp', +new Date());
|
script.setAttribute('data-timestamp', Number(new Date()));
|
||||||
dom.appendTo(dom.body, script);
|
dom.appendTo(dom.body, script);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
2
lib/plugins/disqus.min.js
vendored
2
lib/plugins/disqus.min.js
vendored
|
|
@ -1 +1 @@
|
||||||
!function(){var i=location.href.replace("/-/","/#/");i!==location.href&&(location.href=i);$docsify.plugins=[].concat(function(i,t){var e=Docsify.dom,o=t.config.disqus;if(!o)throw Error("$docsify.disqus is required");i.init(function(i){var t=e.create("script");t.async=!0,t.src="https://"+o+".disqus.com/embed.js",t.setAttribute("data-timestamp",+new Date),e.appendTo(e.body,t)}),i.mounted(function(i){var o=e.create("div");o.id="disqus_thread";var n=e.getNode("#main");o.style="width: "+n.clientWidth+"px; margin: 0 auto 20px;",e.appendTo(e.find(".content"),o),window.disqus_config=function(){this.page.url=location.origin+"/-"+t.route.path,this.page.identifier=t.route.path,this.page.title=document.title}}),i.doneEach(function(i){void 0!==window.DISQUS&&window.DISQUS.reset({reload:!0,config:function(){this.page.url=location.origin+"/-"+t.route.path,this.page.identifier=t.route.path,this.page.title=document.title}})})},$docsify.plugins)}();
|
!function(){var i=location.href.replace("/-/","/#/");i!==location.href&&(location.href=i);$docsify.plugins=[].concat(function(i,t){var e=Docsify.dom,o=t.config.disqus;if(!o)throw Error("$docsify.disqus is required");i.init(function(i){var t=e.create("script");t.async=!0,t.src="https://"+o+".disqus.com/embed.js",t.setAttribute("data-timestamp",Number(new Date)),e.appendTo(e.body,t)}),i.mounted(function(i){var o=e.create("div");o.id="disqus_thread";var n=e.getNode("#main");o.style="width: "+n.clientWidth+"px; margin: 0 auto 20px;",e.appendTo(e.find(".content"),o),window.disqus_config=function(){this.page.url=location.origin+"/-"+t.route.path,this.page.identifier=t.route.path,this.page.title=document.title}}),i.doneEach(function(i){void 0!==window.DISQUS&&window.DISQUS.reset({reload:!0,config:function(){this.page.url=location.origin+"/-"+t.route.path,this.page.identifier=t.route.path,this.page.title=document.title}})})},$docsify.plugins)}();
|
||||||
|
|
|
||||||
|
|
@ -888,12 +888,12 @@ var AllGithubEmoji = [
|
||||||
'zzz'
|
'zzz'
|
||||||
];
|
];
|
||||||
|
|
||||||
// emoji from All-Github-Emoji-Icons
|
// Emoji from All-Github-Emoji-Icons
|
||||||
// https://github.com/scotch-io/All-Github-Emoji-Icons
|
// https://github.com/scotch-io/All-Github-Emoji-Icons
|
||||||
window.emojify = function (match, $1) {
|
window.emojify = function (match, $1) {
|
||||||
return AllGithubEmoji.indexOf($1) === -1
|
return AllGithubEmoji.indexOf($1) === -1 ?
|
||||||
? match
|
match :
|
||||||
: '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' +
|
'<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' +
|
||||||
$1 +
|
$1 +
|
||||||
'.png" alt="' +
|
'.png" alt="' +
|
||||||
$1 +
|
$1 +
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
(function () {
|
(function () {
|
||||||
function install (hook, vm) {
|
function install(hook) {
|
||||||
var dom = Docsify.dom;
|
var dom = Docsify.dom;
|
||||||
|
|
||||||
hook.mounted(function (_) {
|
hook.mounted(function (_) {
|
||||||
|
|
|
||||||
2
lib/plugins/gitalk.min.js
vendored
2
lib/plugins/gitalk.min.js
vendored
|
|
@ -1 +1 @@
|
||||||
!function(){$docsify.plugins=[].concat(function(n,t){var i=Docsify.dom;n.mounted(function(n){var t=i.create("div");t.id="gitalk-container";var e=i.getNode("#main");t.style="width: "+e.clientWidth+"px; margin: 0 auto 20px;",i.appendTo(i.find(".content"),t);var o=i.create("script");o.textContent="gitalk.render('gitalk-container')",i.appendTo(i.body,o)})},$docsify.plugins)}();
|
!function(){$docsify.plugins=[].concat(function(n){var t=Docsify.dom;n.mounted(function(n){var i=t.create("div");i.id="gitalk-container";var e=t.getNode("#main");i.style="width: "+e.clientWidth+"px; margin: 0 auto 20px;",t.appendTo(t.find(".content"),i);var o=t.create("script");o.textContent="gitalk.render('gitalk-container')",t.appendTo(t.body,o)})},$docsify.plugins)}();
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,17 @@ function escapeHtml (string) {
|
||||||
'<': '<',
|
'<': '<',
|
||||||
'>': '>',
|
'>': '>',
|
||||||
'"': '"',
|
'"': '"',
|
||||||
"'": ''',
|
'\'': ''',
|
||||||
'/': '/'
|
'/': '/'
|
||||||
};
|
};
|
||||||
|
|
||||||
return String(string).replace(/[&<>"'\/]/g, function (s) { return entityMap[s]; })
|
return String(string).replace(/[&<>"'/]/g, function (s) { return entityMap[s]; })
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllPaths(router) {
|
function getAllPaths(router) {
|
||||||
var paths = [];
|
var paths = [];
|
||||||
|
|
||||||
helper.dom.findAll('a:not([data-nosearch])').map(function (node) {
|
helper.dom.findAll('a:not([data-nosearch])').forEach(function (node) {
|
||||||
var href = node.href;
|
var href = node.href;
|
||||||
var originHref = node.getAttribute('href');
|
var originHref = node.getAttribute('href');
|
||||||
var path = router.parse(href).path;
|
var path = router.parse(href).path;
|
||||||
|
|
@ -53,17 +53,17 @@ function genIndex (path, content, router, depth) {
|
||||||
slug = router.toURL(path, {id: slugify(token.text)});
|
slug = router.toURL(path, {id: slugify(token.text)});
|
||||||
index[slug] = {slug: slug, title: token.text, body: ''};
|
index[slug] = {slug: slug, title: token.text, body: ''};
|
||||||
} else {
|
} else {
|
||||||
if (!slug) { return }
|
if (!slug) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!index[slug]) {
|
if (!index[slug]) {
|
||||||
index[slug] = {slug: slug, title: '', body: ''};
|
index[slug] = {slug: slug, title: '', body: ''};
|
||||||
} else {
|
} else if (index[slug].body) {
|
||||||
if (index[slug].body) {
|
|
||||||
index[slug].body += '\n' + (token.text || '');
|
index[slug].body += '\n' + (token.text || '');
|
||||||
} else {
|
} else {
|
||||||
index[slug].body = token.text;
|
index[slug].body = token.text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
slugify.clear();
|
slugify.clear();
|
||||||
return index
|
return index
|
||||||
|
|
@ -81,7 +81,7 @@ function search (query) {
|
||||||
});
|
});
|
||||||
|
|
||||||
query = query.trim();
|
query = query.trim();
|
||||||
var keywords = query.split(/[\s\-\,\\/]+/);
|
var keywords = query.split(/[\s\-,\\/]+/);
|
||||||
if (keywords.length !== 1) {
|
if (keywords.length !== 1) {
|
||||||
keywords = [].concat(query, keywords);
|
keywords = [].concat(query, keywords);
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +95,7 @@ function search (query) {
|
||||||
var postUrl = post.slug || '';
|
var postUrl = post.slug || '';
|
||||||
|
|
||||||
if (postTitle && postContent) {
|
if (postTitle && postContent) {
|
||||||
keywords.forEach(function (keyword, i) {
|
keywords.forEach(function (keyword) {
|
||||||
// From https://github.com/sindresorhus/escape-string-regexp
|
// From https://github.com/sindresorhus/escape-string-regexp
|
||||||
var regEx = new RegExp(
|
var regEx = new RegExp(
|
||||||
keyword.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'),
|
keyword.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'),
|
||||||
|
|
@ -111,7 +111,9 @@ function search (query) {
|
||||||
isMatch = false;
|
isMatch = false;
|
||||||
} else {
|
} else {
|
||||||
isMatch = true;
|
isMatch = true;
|
||||||
if (indexContent < 0) { indexContent = 0; }
|
if (indexContent < 0) {
|
||||||
|
indexContent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
var start = 0;
|
var start = 0;
|
||||||
var end = 0;
|
var end = 0;
|
||||||
|
|
@ -119,7 +121,9 @@ function search (query) {
|
||||||
start = indexContent < 11 ? 0 : indexContent - 10;
|
start = indexContent < 11 ? 0 : indexContent - 10;
|
||||||
end = start === 0 ? 70 : indexContent + keyword.length + 60;
|
end = start === 0 ? 70 : indexContent + keyword.length + 60;
|
||||||
|
|
||||||
if (end > postContent.length) { end = postContent.length; }
|
if (end > postContent.length) {
|
||||||
|
end = postContent.length;
|
||||||
|
}
|
||||||
|
|
||||||
var matchContent =
|
var matchContent =
|
||||||
'...' +
|
'...' +
|
||||||
|
|
@ -168,7 +172,9 @@ function init$1 (config, vm) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
paths.forEach(function (path) {
|
paths.forEach(function (path) {
|
||||||
if (INDEXS[path]) { return count++ }
|
if (INDEXS[path]) {
|
||||||
|
return count++
|
||||||
|
}
|
||||||
|
|
||||||
helper
|
helper
|
||||||
.get(vm.router.getFile(path), false, vm.config.requestHeaders)
|
.get(vm.router.getFile(path), false, vm.config.requestHeaders)
|
||||||
|
|
@ -239,7 +245,7 @@ function bindEvents () {
|
||||||
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
|
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
|
||||||
});
|
});
|
||||||
Docsify.dom.on($inputWrap, 'click', function (e) {
|
Docsify.dom.on($inputWrap, 'click', function (e) {
|
||||||
// click input outside
|
// Click input outside
|
||||||
if (e.target.tagName !== 'INPUT') {
|
if (e.target.tagName !== 'INPUT') {
|
||||||
$input.value = '';
|
$input.value = '';
|
||||||
doSearch();
|
doSearch();
|
||||||
|
|
@ -250,7 +256,9 @@ function bindEvents () {
|
||||||
function updatePlaceholder(text, path) {
|
function updatePlaceholder(text, path) {
|
||||||
var $input = Docsify.dom.getNode('.search input[type="search"]');
|
var $input = Docsify.dom.getNode('.search input[type="search"]');
|
||||||
|
|
||||||
if (!$input) { return }
|
if (!$input) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (typeof text === 'string') {
|
if (typeof text === 'string') {
|
||||||
$input.placeholder = text;
|
$input.placeholder = text;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
2
lib/plugins/search.min.js
vendored
2
lib/plugins/search.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -37,5 +37,5 @@
|
||||||
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
|
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": "4.6.4"
|
"version": "4.6.5"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "docsify-server-renderer",
|
"name": "docsify-server-renderer",
|
||||||
"version": "4.6.4",
|
"version": "4.6.5",
|
||||||
"description": "docsify server renderer",
|
"description": "docsify server renderer",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "qingwei-li",
|
"name": "qingwei-li",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue