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