diff --git a/README.md b/README.md index 6b15d722c2..70c0e1e08c 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,6 @@ index.html ``` -Or create a `404.html` and `README.md` into `/docs`. Just remove `data-router` - -```html - -``` - ## CDN - UNPKG [https://unpkg.com/docsify/](https://unpkg.com/docsify/) - jsDelivr [http://www.jsdelivr.com/projects/docsify](http://www.jsdelivr.com/projects/docsify) diff --git a/app.js b/app.js index e960cf44da..ecce401971 100644 --- a/app.js +++ b/app.js @@ -4,8 +4,8 @@ var fs = require('fs') http.createServer(function (req, res) { serveStatic('.')(req, res, function () { - res.writeHead(404, { 'Content-Type': 'text/html' }) - res.end(fs.readFileSync('404.dev.html')) + res.writeHead(200, { 'Content-Type': 'text/html' }) + res.end(fs.readFileSync('dev.html')) }) }).listen(3000, '0.0.0.0') diff --git a/404.dev.html b/dev.html similarity index 100% rename from 404.dev.html rename to dev.html diff --git a/docs/README.md b/docs/README.md index 8e293e50f0..2513e46fb2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,7 +8,7 @@ mkdir docs && cd docs ``` ### Create entry file -Create a `404.html` file +Create a `index.html` file ```html @@ -20,7 +20,7 @@ Create a `404.html` file
- + ``` @@ -77,19 +77,18 @@ Minified files ## More ### Multiple pages -If you need other pages, directly create the markdown file, such as `guide.md` is `/guide`. +If you need other pages, directly create the markdown file, such as `guide.md` is `/#/guide`. ### Navbar -Code in `404.html` +Code in `index.html` ```html ``` - ### CDN - UNPKG [https://unpkg.com/docsify/](https://unpkg.com/docsify/) - jsDelivr [http://www.jsdelivr.com/projects/docsify](http://www.jsdelivr.com/projects/docsify) @@ -234,7 +233,7 @@ If you write a sub level list, it will generate a dropdown list. #### router -Hash router. You can replace `404.html` with `index.html`. +Hash router. ```html diff --git a/docs/_media/snow.js b/docs/_media/snow.js new file mode 100644 index 0000000000..b0c20e5052 --- /dev/null +++ b/docs/_media/snow.js @@ -0,0 +1,56 @@ +// Fork https://github.com/HermannBjorgvin/SnowJs/blob/master/snow.js +(function(){ + var canvas = document.createElement("canvas"); + var ctx = canvas.getContext("2d"); + var flakeArray = []; + + canvas.style.pointerEvents = "none"; + canvas.style.position = "absolute"; + canvas.style.top = 0; + canvas.style.left = 0; + canvas.style.width = "100vw"; + canvas.style.height = "100vh"; + document.body.appendChild(canvas); + + function canvasResize(){ + canvas.height = canvas.offsetHeight; + canvas.width = canvas.offsetWidth; + } + canvasResize(); + + window.onresize = function() { + canvasResize(); + }; + + var MyMath = Math; + + setInterval(function() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.beginPath(); + + var random = MyMath.random(); + var distance = .05 + .95 * random; + + flake = {}; + flake.x = 1.5 * canvas.width * MyMath.random() - .5 * canvas.width; + flake.y = -9; + flake.velX = 2 * distance * (MyMath.random() / 2 + .5); + flake.velY = (4 + 2 * MyMath.random()) * distance; + flake.radius = MyMath.pow(5 * random, 2) / 5; + flake.update = function() { + var t = this; + t.x += t.velX; + t.y += t.velY; + ctx.beginPath(); + ctx.arc(t.x, t.y, t.radius, 0, 2 * MyMath.PI, !1); + ctx.fillStyle = "#FFF"; + ctx.fill() + }; + + flakeArray.push(flake); + + for (b = 0; b < flakeArray.length; b++) { + flakeArray[b].y > canvas.height ? flakeArray.splice(b, 1) : flakeArray[b].update() + } + }, 16); +})(); \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 615ba0c70e..1bb458e727 100644 --- a/docs/index.html +++ b/docs/index.html @@ -15,6 +15,7 @@
+ + ``` @@ -66,7 +66,7 @@ docsify serve docs 更多选项参考 [docsify-cli](https://github.com/QingWei-Li/docsify-cli) ## 主题 -目前提供 vue.css 和 buble.css,直接修改 `404.html` 里的 cdn 地址即可 +目前提供 vue.css 和 buble.css,直接修改 `index.html` 里的 cdn 地址即可 ```html @@ -82,19 +82,20 @@ docsify serve docs ## 更多功能 ### 多页面 -`README.md` 作为主页面,如果需要其他页面,直接在文档目录下创建对应的 `*.md` 文件,例如创建一个 `guide.md` 那么对应的路由就是 `/guide`。 +`README.md` 作为主页面,如果需要其他页面,直接在文档目录下创建对应的 `*.md` 文件,例如创建一个 `guide.md` 那么对应的路由就是 `/#/guide`。 ### 导航 -导航需要自己写在 `404.html` 文件里,效果参考本文档 +导航需要自己写在 `index.html` 文件里,效果参考本文档 ```html ``` + ### CDN - UNPKG [https://unpkg.com/docsify/](https://unpkg.com/docsify/) - jsDelivr [http://www.jsdelivr.com/projects/docsify](http://www.jsdelivr.com/projects/docsify) @@ -124,7 +125,7 @@ docsify serve docs ### 配置参数 #### repo -参考本文档的右上角的 GitHub 图标,如果要开启的话,将 `404.html` 里的 script 改成 +参考本文档的右上角的 GitHub 图标,如果要开启的话,将 `index.html` 里的 script 改成 ```html @@ -237,7 +238,7 @@ Sidebar 开关按钮 #### router -开启 hash router 功能,此时可以创建 `index.html` 作为入口文件,同时多页面切换不会重新加载资源。资源路径会被替换成 `/#/` 的形式。 +开启 hash router 功能,同时多页面切换不会重新加载资源。资源路径会被替换成 `/#/` 的形式。 ```html diff --git a/lib/docsify.js b/lib/docsify.js index 26a9b027ab..69fa4c2b94 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -2456,6 +2456,7 @@ function renderArticle (content) { renderSidebar.rendered = false; renderNavbar.rendered = false; + if (typeof Vue !== 'undefined' && typeof Vuep !== 'undefined') { new Vue({ el: 'main' }); } // eslint-disable-line if (OPTIONS$1.auto2top) { scroll2Top(); } } diff --git a/lib/docsify.min.js b/lib/docsify.min.js index bb2f6d7ed4..7d75ebb8be 100644 --- a/lib/docsify.min.js +++ b/lib/docsify.min.js @@ -1,2 +1,2 @@ -var Docsify=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){if(void 0===t&&(t=function(){}),n){var i=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(i)})}r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var i=e.level||1,a=i-1;i>t||(r[a]?(r[a].children=r[a].children||[],r[a].children.push(e)):n.push(e),r[i]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function i(){var e=window.location;if(A===e.hash&&!r(C))return C;var t=e.hash.match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,C=t,A=e.hash,t}function a(){return document.body.clientWidth<=600}function s(){function e(){for(var e=0,r=t.length;e10){var o=n[a.getAttribute("data-id")];if(!o||o===i)return;return i&&i.setAttribute("class",""),o.setAttribute("class","active"),void(i=o)}}}if(!a()){for(var t=document.querySelectorAll(".anchor"),n={},r=document.querySelectorAll(".sidebar li"),i=null,s=0,o=r.length;s=t||e.classList.contains("hidden")?document.body.classList.add("sticky"):document.body.classList.remove("sticky")}()}function p(e,t){return t={exports:{}},e(t,t.exports),t.exports}function g(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n \n \n '):""}function h(e){return"
\n "+e+'\n \n
\n
\n
\n
'}function f(){var e=", 100%, 85%",t="linear-gradient(to left bottom, hsl("+(Math.floor(255*Math.random())+e)+") 0%, hsl("+(Math.floor(255*Math.random())+e)+") 100%)";return'
\n
\n
'}function m(){return''}function b(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
  • '+e.title+"
  • ",e.children&&(t+='
    • '+b(e.children)+"
    ")}),t):""}function y(e,t){var n=document.querySelector("nav")||document.createElement("nav");j.repo||n.classList.add("no-badge"),e[t?"outerHTML":"innerHTML"]=g(j.repo)+(j.coverpage?f():"")+h(j.sidebarToggle?m():""),document.body.insertBefore(n,document.body.children[0]),u("button.sidebar-toggle"),j.coverpage?!a()&&window.addEventListener("scroll",d):document.body.classList.add("sticky")}function v(e){N("article",e?E(e):"not found"),x.rendered||x(null,j),k.rendered||k(null,j),x.rendered=!1,k.rendered=!1,j.auto2top&&c()}function k(e){T.navbar&&T.navbar===e||(T.navbar=e,k.rendered=!0,e&&N("nav",E(e)),l("nav"))}function x(e){var n=!1;e?e=E(e):j.sidebar?e=b(j.sidebar,"