Compare commits

...
23 Commits
Author SHA1 Message Date
qingwei.li 0e615abbdc -> v1.3.5 2016-12-25 20:13:21 +08:00
qingwei.li cb2b191ba1 bump 1.3.5 2016-12-25 20:13:11 +08:00
qingwei.li 6adcfffba9 fix vue 2016-12-25 20:12:03 +08:00
qingwei.li f165470265 -> v1.3.4 2016-12-25 18:34:14 +08:00
qingwei.li bbb7b4a9d6 bump 1.3.4 2016-12-25 18:33:57 +08:00
qingwei.li 540095ee35 Support vuep 2016-12-25 18:33:12 +08:00
qingwei.li bd354094c0 🎄 Merry Christmas 2016-12-24 20:32:04 +08:00
qingwei.li 6e81e66441 404.dev => dev 2016-12-24 19:50:41 +08:00
qingwei.li 67f9083ff7 Remove 404.html 2016-12-24 19:50:04 +08:00
qingwei.li 383b976ddd Update docs 2016-12-24 11:33:48 +08:00
qingwei.li 54ba970552 -> v1.3.3 2016-12-23 21:47:42 +08:00
qingwei.li 16623c9301 bump 1.3.3 2016-12-23 21:47:31 +08:00
qingwei.li 668c5ca714 fix lint 2016-12-23 21:47:15 +08:00
qingwei.li d0861d7427 Fixed cover rendering timing 2016-12-23 21:46:12 +08:00
qingwei.li 97669e0d28 Add similar projects into readme 2016-12-23 09:25:30 +08:00
qingwei.li a0408b7a38 -> v1.3.2 2016-12-23 01:20:57 +08:00
qingwei.li f917da8214 bump 1.3.2 2016-12-23 01:20:47 +08:00
qingwei.li 64309beee9 Fixed render link 2016-12-23 01:20:28 +08:00
qingwei.li 4c8c0349e6 -> v1.3.1 2016-12-23 00:25:05 +08:00
qingwei.li 91b6720219 bump 1.3.1 2016-12-23 00:24:45 +08:00
qingwei.li c93ba1ea16 Fixed cover page style 2016-12-23 00:24:24 +08:00
qingwei.li 4f5a150c17 update cdn 2016-12-22 01:03:52 +08:00
qingwei.li 801df6ae3e Update changelog
Update changelog
2016-12-22 00:30:30 +08:00
18 changed files with 153 additions and 61 deletions
+1
View File
@@ -1,3 +1,4 @@
.DS_Store
*.log
node_modules
yarn.lock
+31 -3
View File
@@ -1,12 +1,40 @@
## 1.3.5
### Bug fixes
- Fix vue
## 1.3.4
### Bug fixes
- Supports [vuep](https://github.com/QingWei-Li/vuep)
## 1.3.3
### Bug fixes
- Fixed cover rendering timing
## 1.3.2
### Bug fixes
- Fixed render link
## 1.3.1
### Bug fixes
- Fixed cover page style
- Generate the correct link when rendering the article
## 1.3.0
### Features
- Add cover page
- add `<kbd>` style
- headling can be cliked
### Bug fixes
- sidebar highlight
- headling can be cliked
- add `<kbd>` style
### break change
- Navbar no longer fixed at the top
## 1.2.0
### Features
+4 -6
View File
@@ -42,12 +42,6 @@ index.html
</html>
```
Or create a `404.html` and `README.md` into `/docs`. Just remove `data-router`
```html
<script src="//unpkg.com/docsify"></script>
```
## CDN
- UNPKG [https://unpkg.com/docsify/](https://unpkg.com/docsify/)
- jsDelivr [http://www.jsdelivr.com/projects/docsify](http://www.jsdelivr.com/projects/docsify)
@@ -58,6 +52,10 @@ These open-source projects are using docsify to generate their sites. Pull reque
- [docsify](https://docsify.js.org) - A magical documentation site generator.
- [Snipaste](https://docs.snipaste.com/) - A new way to boost your productivity.
## Similar projects
- [docute](https://github.com/egoist/docute) - 📜 Effortlessly documentation done right
- [docpress](https://github.com/docpress/docpress) - Documentation website generator
## Contributing
- Fork it!
+2 -2
View File
@@ -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')
View File
+7 -8
View File
@@ -8,7 +8,7 @@ mkdir docs && cd docs
```
### Create entry file
Create a `404.html` file
Create a `index.html` file
```html
<!DOCTYPE html>
@@ -20,7 +20,7 @@ Create a `404.html` file
<body>
<div id="app"></div>
</body>
<script src="//unpkg.com/docsify"></script>
<script src="//unpkg.com/docsify" data-router></script>
</html>
```
@@ -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
<nav>
<a href="/docsify/">En</a>
<a href="/docsify/zh-cn">中文</a>
<a href="/#/docsify/">En</a>
<a href="/#/docsify/zh-cn">中文</a>
</nav>
```
### 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
<script src="/lib/docsify.js" data-router></script>
+1 -1
View File
@@ -1,6 +1,6 @@
![logo](_media/icon.svg)
# docsify <small>1.3.0</small>
# docsify <small>1.3.3</small>
> A magical documentation site generator.
+56
View File
@@ -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);
})();
+3 -2
View File
@@ -6,7 +6,7 @@
<link rel="icon" href="favicon.ico">
<meta name="description" content="A magical documentation generator.">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/docsify/latest/lib/themes/vue.css">
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
</head>
<body>
<nav>
@@ -15,8 +15,9 @@
</nav>
<div id="app"></div>
</body>
<script src="_media/snow.js"></script>
<script
src="//cdn.jsdelivr.net/docsify/latest/lib/docsify.min.js"
src="//unpkg.com/docsify/lib/docsify.min.js"
data-max-level="4"
data-sidebar-toggle
data-coverpage
+10 -9
View File
@@ -14,7 +14,7 @@ mkdir docs && cd docs
```
### 创建入口文件
创建一个 `404.html` 文件,内容为
创建一个 `index.html` 文件,内容为
```html
<!DOCTYPE html>
<html>
@@ -25,7 +25,7 @@ mkdir docs && cd docs
<body>
<div id="app"></div>
</body>
<script src="//unpkg.com/docsify"></script>
<script src="//unpkg.com/docsify" data-router></script>
</html>
```
@@ -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
<link rel="stylesheet" href="//unpkg.com/docsify/themes/vue.css">
<link rel="stylesheet" href="//unpkg.com/docsify/themes/buble.css">
@@ -82,19 +82,20 @@ docsify serve docs
## 更多功能
### 多页面
`README.md` 作为主页面,如果需要其他页面,直接在文档目录下创建对应的 `*.md` 文件,例如创建一个 `guide.md` 那么对应的路由就是 `/guide`
`README.md` 作为主页面,如果需要其他页面,直接在文档目录下创建对应的 `*.md` 文件,例如创建一个 `guide.md` 那么对应的路由就是 `/#/guide`
### 导航
导航需要自己写在 `404.html` 文件里,效果参考本文档
导航需要自己写在 `index.html` 文件里,效果参考本文档
```html
<nav>
<a href="/docsify/">En</a>
<a href="/docsify/zh-cn">中文</a>
<a href="/#/docsify/">En</a>
<a href="/#/docsify/zh-cn">中文</a>
</nav>
```
### 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
<script src="//unpkg.com/docsify" data-repo="your/repo"></script>
@@ -237,7 +238,7 @@ Sidebar 开关按钮
#### router
开启 hash router 功能,此时可以创建 `index.html` 作为入口文件,同时多页面切换不会重新加载资源。资源路径会被替换成 `/#/` 的形式。
开启 hash router 功能,同时多页面切换不会重新加载资源。资源路径会被替换成 `/#/` 的形式。
```html
<script src="/lib/docsify.js" data-router></script>
+11 -9
View File
@@ -2410,13 +2410,14 @@ renderer.heading = function (text, level) {
renderer.code = function (code, lang) {
if ( lang === void 0 ) lang = '';
var hl = prism.highlight(code, prism.languages[lang] || prism.languages.markup);
var hl = prism.highlight(code, prism.languages[lang] || prism.languages.markup)
.replace(/{{/g, '<span>{{</span>');
return ("<pre data-lang=\"" + lang + "\"><code class=\"lang-" + lang + "\">" + hl + "</code></pre>")
};
renderer.link = function (href, title, text) {
if (OPTIONS$1.router && !/^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/.test(href)) {
href = !/^\/#/.test(href) ? ("#" + href) : href;
href = ("#/" + href).replace(/\/\//g, '/');
}
return ("<a href=\"" + href + "\" title=\"" + (title || '') + "\">" + text + "</a>")
@@ -2456,6 +2457,7 @@ function renderArticle (content) {
renderSidebar.rendered = false;
renderNavbar.rendered = false;
if (content && typeof Vue !== 'undefined' && typeof Vuep !== 'undefined') { new Vue({ el: 'main' }); } // eslint-disable-line
if (OPTIONS$1.auto2top) { scroll2Top(); }
}
@@ -2506,6 +2508,8 @@ function renderCover (content) {
!renderCover.rendered && renderTo('.cover-main', marked(content));
renderCover.rendered = true;
}
sticky();
}
/**
@@ -2610,12 +2614,8 @@ var mainRender = function (cb) {
}
// Render Cover page
if (OPTIONS.coverpage) {
if (page === OPTIONS.homepage) {
load(OPTIONS.coverpage).then(renderCover);
} else {
renderCover();
}
if (OPTIONS.coverpage && page === OPTIONS.homepage) {
load(OPTIONS.coverpage).then(renderCover);
}
cacheXhr && cacheXhr.abort && cacheXhr.abort();
@@ -2623,6 +2623,9 @@ var mainRender = function (cb) {
cacheXhr = load(page, 'GET', renderLoading);
cacheXhr.then(function (result) {
renderArticle(result);
// clear cover
if (OPTIONS.coverpage && page !== OPTIONS.homepage) { renderCover(); }
// render sidebar
if (OPTIONS.loadSidebar) {
if (wait === false) { cb(); }
wait = false;
@@ -2653,7 +2656,6 @@ var Docsify = function () {
mainRender(function (_) {
activeLink('aside.sidebar', true);
scrollIntoView();
OPTIONS.coverpage && sticky();
});
};
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docsify",
"version": "1.3.0",
"version": "1.3.5",
"description": "A magical documentation generator.",
"main": "lib/docsify.js",
"files": [
+6 -8
View File
@@ -1,5 +1,5 @@
import { load, camel2kebab, isNil, getRoute } from './util'
import { activeLink, scrollIntoView, sticky } from './event'
import { activeLink, scrollIntoView } from './event'
import * as render from './render'
const OPTIONS = {
@@ -59,12 +59,8 @@ const mainRender = function (cb) {
}
// Render Cover page
if (OPTIONS.coverpage) {
if (page === OPTIONS.homepage) {
load(OPTIONS.coverpage).then(render.renderCover)
} else {
render.renderCover()
}
if (OPTIONS.coverpage && page === OPTIONS.homepage) {
load(OPTIONS.coverpage).then(render.renderCover)
}
cacheXhr && cacheXhr.abort && cacheXhr.abort()
@@ -72,6 +68,9 @@ const mainRender = function (cb) {
cacheXhr = load(page, 'GET', render.renderLoading)
cacheXhr.then(result => {
render.renderArticle(result)
// clear cover
if (OPTIONS.coverpage && page !== OPTIONS.homepage) render.renderCover()
// render sidebar
if (OPTIONS.loadSidebar) {
if (wait === false) cb()
wait = false
@@ -102,7 +101,6 @@ const Docsify = function () {
mainRender(_ => {
activeLink('aside.sidebar', true)
scrollIntoView()
OPTIONS.coverpage && sticky()
})
}
+5 -1
View File
@@ -37,12 +37,13 @@ renderer.heading = function (text, level) {
// highlight code
renderer.code = function (code, lang = '') {
const hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
.replace(/{{/g, '<span>{{</span>')
return `<pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
}
renderer.link = function (href, title, text) {
if (OPTIONS.router && !/^(?:\w+:)?\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/.test(href)) {
href = !/^\/#/.test(href) ? `#${href}` : href
href = `#/${href}`.replace(/\/\//g, '/')
}
return `<a href="${href}" title="${title || ''}">${text}</a>`
@@ -82,6 +83,7 @@ export function renderArticle (content) {
renderSidebar.rendered = false
renderNavbar.rendered = false
if (content && typeof Vue !== 'undefined' && typeof Vuep !== 'undefined') new Vue({ el: 'main' }) // eslint-disable-line
if (OPTIONS.auto2top) scroll2Top()
}
@@ -132,6 +134,8 @@ export function renderCover (content) {
!renderCover.rendered && renderTo('.cover-main', marked(content))
renderCover.rendered = true
}
sticky()
}
/**
+11 -7
View File
@@ -1,14 +1,14 @@
section.cover {
height: 100vh;
display: flex;
align-items: center;
&.hidden {
display: none;
}
height: 100vh;
position: relative;
.cover-main {
position: absolute 0 0 0 0;
padding: 20vh 0;
flex: 1;
text-align: center;
margin: 0 16px;
}
@@ -22,6 +22,11 @@ section.cover {
}
}
p {
margin: 1em 0;
line-height: 1.5rem;
}
h1 {
text-align: center;
font-size: 2.5rem;
@@ -50,8 +55,7 @@ section.cover {
line-height: 1.8;
}
p a {
margin-top: 1em;
.cover-main p:last-child a {
border-radius: 2em;
border: 1px solid $color-primary;
box-sizing: border-box;