mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
[build] 4.0.0 next
This commit is contained in:
parent
d4f6072d10
commit
b9b9d87681
@ -12,7 +12,7 @@ echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Releasing $VERSION ..."
|
||||
|
||||
npm run lint
|
||||
npm run test
|
||||
|
||||
# build
|
||||
VERSION=$VERSION npm run build
|
||||
@ -29,8 +29,8 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
|
||||
# commit
|
||||
git add -A
|
||||
git commit -m "[build] $VERSION"
|
||||
npm version $VERSION --message "[release] $VERSION"
|
||||
git commit -m "[build] $VERSION $RELEASE_TAG"
|
||||
npm version $VERSION --message "[release] $VERSION $RELEASE_TAG"
|
||||
|
||||
# publish
|
||||
git push origin refs/tags/v$VERSION
|
||||
|
||||
1322
lib/docsify.js
1322
lib/docsify.js
File diff suppressed because it is too large
Load Diff
4
lib/docsify.min.js
vendored
4
lib/docsify.min.js
vendored
File diff suppressed because one or more lines are too long
@ -11,24 +11,28 @@ function appendScript () {
|
||||
}
|
||||
|
||||
function init (id) {
|
||||
if (!window.ga) {
|
||||
var ga = window.ga;
|
||||
|
||||
if (!ga) {
|
||||
appendScript();
|
||||
window.ga = window.ga || function () {
|
||||
(window.ga.q = window.ga.q || []).push(arguments);
|
||||
ga = ga || function () {
|
||||
(ga.q = ga.q || []).push(arguments);
|
||||
};
|
||||
window.ga.l = Number(new Date());
|
||||
window.ga('create', id, 'auto');
|
||||
ga.l = Number(new Date());
|
||||
ga('create', id, 'auto');
|
||||
}
|
||||
return ga
|
||||
}
|
||||
|
||||
function collect () {
|
||||
init(window.$docsify.ga);
|
||||
window.ga('set', 'page', location.hash);
|
||||
window.ga('send', 'pageview');
|
||||
var ga = init($docsify.ga);
|
||||
|
||||
ga('set', 'page', location.hash);
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
|
||||
var install = function (hook) {
|
||||
if (!window.$docsify.ga) {
|
||||
if (!$docsify.ga) {
|
||||
console.error('[Docsify] ga is required.');
|
||||
return
|
||||
}
|
||||
@ -36,6 +40,6 @@ var install = function (hook) {
|
||||
hook.beforeEach(collect);
|
||||
};
|
||||
|
||||
window.$docsify.plugins = [].concat(install, window.$docsify.plugins);
|
||||
$docsify.plugins = [].concat(install, $docsify.plugins);
|
||||
|
||||
}());
|
||||
|
||||
2
lib/plugins/ga.min.js
vendored
2
lib/plugins/ga.min.js
vendored
@ -1 +1 @@
|
||||
this.D=this.D||{},function(){"use strict";function n(){var n=document.createElement("script");n.async=!0,n.src="https://www.google-analytics.com/analytics.js",document.body.appendChild(n)}function i(i){window.ga||(n(),window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=Number(new Date),window.ga("create",i,"auto"))}function o(){i(window.$docsify.ga),window.ga("set","page",location.hash),window.ga("send","pageview")}var w=function(n){if(!window.$docsify.ga)return void console.error("[Docsify] ga is required.");n.beforeEach(o)};window.$docsify.plugins=[].concat(w,window.$docsify.plugins)}();
|
||||
this.D=this.D||{},function(){"use strict";function n(){var n=document.createElement("script");n.async=!0,n.src="https://www.google-analytics.com/analytics.js",document.body.appendChild(n)}function c(c){var e=window.ga;return e||(n(),e=e||function(){(e.q=e.q||[]).push(arguments)},e.l=Number(new Date),e("create",c,"auto")),e}function e(){var n=c($docsify.ga);n("set","page",location.hash),n("send","pageview")}var i=function(n){if(!$docsify.ga)return void console.error("[Docsify] ga is required.");n.beforeEach(e)};$docsify.plugins=[].concat(i,$docsify.plugins)}();
|
||||
|
||||
@ -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);
|
||||
|
||||
}());
|
||||
|
||||
2
lib/plugins/search.min.js
vendored
2
lib/plugins/search.min.js
vendored
@ -1 +1 @@
|
||||
this.D=this.D||{},function(){"use strict";function e(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(){var e=[];return h.dom.findAll("a:not([data-nosearch])").map(function(n){var t=n.href,a=n.getAttribute("href"),r=h.route.parse(t).path;r&&-1===e.indexOf(r)&&!h.route.isAbsolutePath(a)&&e.push(r)}),e}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(y))}function a(e,n){void 0===n&&(n="");var t,a=window.marked.lexer(n),r=window.Docsify.slugify,o=Docsify.route.toURL,i={};return a.forEach(function(n){if("heading"===n.type&&n.depth<=2)t=o(e,{id:r(n.text)}),i[t]={slug:t,title:n.text,body:""};else{if(!t)return;i[t]?i[t].body?i[t].body+="\n"+(n.text||""):i[t].body=n.text:i[t]={slug:t,title:"",body:""}}}),r.clear(),i}function r(n){var t=[],a=[];Object.keys(y).forEach(function(e){a=a.concat(Object.keys(y[e]).map(function(n){return y[e][n]}))}),n=[].concat(n,n.trim().split(/[\s\-\,\\\/]+/));for(var r=0;r<a.length;r++)!function(r){var o=a[r],i=!1,s="",c=o.title&&o.title.trim(),l=o.body&&o.body.trim(),u=o.slug||"";if(c&&l&&(n.forEach(function(n,t){var a=new RegExp(n,"gi"),r=-1,o=-1;if(r=c&&c.search(a),o=l&&l.search(a),r<0&&o<0)i=!1;else{i=!0,o<0&&(o=0);var u=0,p=0;u=o<11?0:o-10,p=0===u?70:o+n.length+60,p>l.length&&(p=l.length);var f="..."+e(l).substring(u,p).replace(a,'<em class="search-keyword">'+n+"</em>")+"...";s+=f}}),i)){var p={title:e(c),content:s,url:u};t.push(p)}}(r);return t}function o(e,r){h=Docsify;var o="auto"===e.paths,i=localStorage.getItem("docsify.search.expires")<Date.now();if(y=JSON.parse(localStorage.getItem("docsify.search.index")),i)y={};else if(!o)return;var s=o?n():e.paths,c=s.length,l=0;s.forEach(function(n){if(y[n])return l++;h.get(r.$getFile(n)).then(function(r){y[n]=a(n,r),c===++l&&t(e.maxAge)})})}function i(){var e=g.create("style","\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}");g.appendTo(g.head,e)}function s(e,n){void 0===n&&(n="");var t='<input type="search" value="'+n+'" /><div class="results-panel"></div></div>',a=g.create("div",t),r=g.find("aside");g.toggleClass(a,"search"),g.before(r,a)}function c(e){var n=g.find("div.search"),t=g.find(n,".results-panel");if(!e)return t.classList.remove("show"),void(t.innerHTML="");var a=r(e),o="";a.forEach(function(e){o+='<div class="matching-post">\n<h2><a href="'+e.url+'">'+e.title+"</a></h2>\n<p>"+e.content+"</p>\n</div>"}),t.classList.add("show"),t.innerHTML=o||'<p class="empty">'+v+"</p>"}function l(){var e,n=g.find("div.search"),t=g.find(n,"input");g.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),g.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return c(n.target.value.trim())},100)})}function u(e,n){var t=g.getNode('.search input[type="search"]');if("string"==typeof e)t.placeholder=e;else{var a=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];t.placeholder=e[a]}}function p(e,n){if("string"==typeof e)v=e;else{var t=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];v=e[t]}}function f(e){g=Docsify.dom;var n=Docsify.route.parse().query.s;i(),s(e,n),l(),n&&setTimeout(function(e){return c(n)},500)}function d(e,n){u(e.placeholder,n.route.path),p(e.noData,n.route.path)}var h,g,y={},v="",m={placeholder:"Type to search",noData:"No Results!",paths:"auto",maxAge:864e5},x=function(e,n){var t=Docsify.util,a=n.config.search||m;Array.isArray(a)?m.paths=a:"object"==typeof a&&(m.paths=Array.isArray(a.paths)?a.paths:"auto",m.maxAge=t.isPrimitive(a.maxAge)?a.maxAge:m.maxAge,m.placeholder=a.placeholder||m.placeholder,m.noData=a.noData||m.noData);var r="auto"===m.paths;e.mounted(function(e){f(m),!r&&o(m,n)}),e.doneEach(function(e){d(m,n),r&&o(m,n)})};window.$docsify.plugins=[].concat(x,window.$docsify.plugins)}();
|
||||
this.D=this.D||{},function(){"use strict";function e(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(e){var n=[];return d.dom.findAll("a:not([data-nosearch])").map(function(t){var r=t.href,a=t.getAttribute("href"),o=e.parse(r).path;o&&-1===n.indexOf(o)&&!Docsify.util.isAbsolutePath(a)&&n.push(o)}),n}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(v))}function r(e,n,t){void 0===n&&(n="");var r,a=window.marked.lexer(n),o=window.Docsify.slugify,i=t.toURL,s={};return a.forEach(function(n){if("heading"===n.type&&n.depth<=2)r=i(e,{id:o(n.text)}),s[r]={slug:r,title:n.text,body:""};else{if(!r)return;s[r]?s[r].body?s[r].body+="\n"+(n.text||""):s[r].body=n.text:s[r]={slug:r,title:"",body:""}}}),o.clear(),s}function a(n){var t=[],r=[];Object.keys(v).forEach(function(e){r=r.concat(Object.keys(v[e]).map(function(n){return v[e][n]}))}),n=[].concat(n,n.trim().split(/[\s\-\,\\\/]+/));for(var a=0;a<r.length;a++)!function(a){var o=r[a],i=!1,s="",c=o.title&&o.title.trim(),l=o.body&&o.body.trim(),u=o.slug||"";if(c&&l&&(n.forEach(function(n,t){var r=new RegExp(n,"gi"),a=-1,o=-1;if(a=c&&c.search(r),o=l&&l.search(r),a<0&&o<0)i=!1;else{i=!0,o<0&&(o=0);var u=0,p=0;u=o<11?0:o-10,p=0===u?70:o+n.length+60,p>l.length&&(p=l.length);var f="..."+e(l).substring(u,p).replace(r,'<em class="search-keyword">'+n+"</em>")+"...";s+=f}}),i)){var p={title:e(c),content:s,url:u};t.push(p)}}(a);return t}function o(e,a){d=Docsify;var o="auto"===e.paths,i=localStorage.getItem("docsify.search.expires")<Date.now();if(v=JSON.parse(localStorage.getItem("docsify.search.index")),i)v={};else if(!o)return;var s=o?n(a.router):e.paths,c=s.length,l=0;s.forEach(function(n){if(v[n])return l++;d.get(a.router.getFile(n)).then(function(o){v[n]=r(n,o,a.router),c===++l&&t(e.maxAge)})})}function i(){var e=g.create("style","\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}");g.appendTo(g.head,e)}function s(e,n){void 0===n&&(n="");var t='<input type="search" value="'+n+'" /><div class="results-panel"></div></div>',r=g.create("div",t),a=g.find("aside");g.toggleClass(r,"search"),g.before(a,r)}function c(e){var n=g.find("div.search"),t=g.find(n,".results-panel");if(!e)return t.classList.remove("show"),void(t.innerHTML="");var r=a(e),o="";r.forEach(function(e){o+='<div class="matching-post">\n<h2><a href="'+e.url+'">'+e.title+"</a></h2>\n<p>"+e.content+"</p>\n</div>"}),t.classList.add("show"),t.innerHTML=o||'<p class="empty">'+y+"</p>"}function l(){var e,n=g.find("div.search"),t=g.find(n,"input");g.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),g.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return c(n.target.value.trim())},100)})}function u(e,n){var t=g.getNode('.search input[type="search"]');if("string"==typeof e)t.placeholder=e;else{var r=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];t.placeholder=e[r]}}function p(e,n){if("string"==typeof e)y=e;else{var t=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];y=e[t]}}function f(e,n){g=Docsify.dom;var t=n.router.parse().query.s;i(),s(e,t),l(),t&&setTimeout(function(e){return c(t)},500)}function h(e,n){u(e.placeholder,n.route.path),p(e.noData,n.route.path)}var d,g,v={},y="",m={placeholder:"Type to search",noData:"No Results!",paths:"auto",maxAge:864e5},x=function(e,n){var t=Docsify.util,r=n.config.search||m;Array.isArray(r)?m.paths=r:"object"==typeof r&&(m.paths=Array.isArray(r.paths)?r.paths:"auto",m.maxAge=t.isPrimitive(r.maxAge)?r.maxAge:m.maxAge,m.placeholder=r.placeholder||m.placeholder,m.noData=r.noData||m.noData);var a="auto"===m.paths;e.mounted(function(e){f(m,n),!a&&o(m,n)}),e.doneEach(function(e){h(m,n),a&&o(m,n)})};$docsify.plugins=[].concat(x,$docsify.plugins)}();
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
"dev": "node app & nodemon -w src -e js,css --exec 'npm run dev:build'",
|
||||
"build:ssr": "node build/build-ssr",
|
||||
"test": "eslint {src,packages} --fix",
|
||||
"pub:next": "RELEASE_TAG=next sh build/release",
|
||||
"pub": "sh build/release"
|
||||
"pub:next": "RELEASE_TAG=next sh build/release.sh",
|
||||
"pub": "sh build/release.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"marked": "^0.3.6",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user