Compare commits

...
39 Commits
Author SHA1 Message Date
qingwei.li b37781e949 [release] 4.1.12 2017-06-03 20:12:32 +08:00
qingwei.li 54a48dd3ff [build] 4.1.12 2017-06-03 20:12:32 +08:00
qingwei.li 1aabc41db7 add changelog 2017-06-03 20:12:08 +08:00
qingwei.li d087d5753b fix(render): ubtitle in side bar shows undefined, fixed #182 2017-06-03 20:11:34 +08:00
qingwei.li bb793ec08e update package size 2017-06-02 22:37:27 +08:00
qingwei.li 6a78ae7ddc [release] 4.1.11 2017-06-02 22:18:36 +08:00
qingwei.li ac28040bd7 [build] 4.1.11 2017-06-02 22:18:36 +08:00
qingwei.li b12f74b159 add changelog 2017-06-02 22:16:39 +08:00
qingwei.li 1304d2ea1a fix(render): autoHeader does not work 2017-06-02 22:14:28 +08:00
qingwei.li ccf4c7c5cc fix(compiler): force reset toc when rendering sidebar fixed #181 2017-06-02 22:12:07 +08:00
qingwei.li 9b15d8d577 update cdn version 2017-06-02 18:04:20 +08:00
qingwei.li 642e7da7ee [release] 4.1.10 2017-06-02 17:57:56 +08:00
qingwei.li 75381cf046 [build] 4.1.10 2017-06-02 17:57:56 +08:00
qingwei.li 7e2e5a7c90 add changelog 2017-06-02 17:57:32 +08:00
qingwei.li 6d48ce1266 fix(hash): hash routing crashes when url has querystring 2017-06-02 17:56:38 +08:00
qingwei.li d286963da0 update readme 2017-06-02 17:41:13 +08:00
qingwei.li 8a4cedd962 replaced unpkg cdn with jsdelivr 2017-06-01 21:25:08 +08:00
Wei Wangandcinwell.li a3b7b66a76 Fix broken footer (#178) 2017-06-01 13:32:39 +08:00
qingwei.li 5a0d4b7897 docs(cdn): update jsdelivr cdn 2017-06-01 10:29:12 +08:00
Michelle Brierandcinwell.li fcfdb17b8d Add license scan badge (#176) 2017-06-01 07:44:19 +08:00
Michelle Brierandcinwell.li e4d2e7ec12 Add license report
Large report badge
2017-06-01 07:43:59 +08:00
qingwei.li ece00e6b3a [release] 4.1.9 2017-05-31 22:32:57 +08:00
qingwei.li 841829427b [build] 4.1.9 2017-05-31 22:32:30 +08:00
qingwei.li 56c7b9ae2d add changelog 2017-05-31 22:20:46 +08:00
qingwei.li db8400a6ac docs: add feature 2017-05-31 22:19:43 +08:00
qingwei.li 955d3d5988 fix(lifecycle): continue to handle data 2017-05-31 21:20:09 +08:00
qingwei.li d9b487e67b fix: can't render toc on first load 2017-05-31 20:42:29 +08:00
qingwei.li 91b66a5cac fix(render): broken name link, fixed #167 2017-05-31 20:35:59 +08:00
qingwei.li 90bba60367 add package-lock.json 2017-05-31 14:22:43 +08:00
qingwei.li d05c4f65a8 add lerna 2017-05-31 10:01:15 +08:00
qingwei.li 3380a62142 [release] 4.1.8 2017-05-31 08:39:22 +08:00
qingwei.li 8e418a1681 [build] 4.1.8 2017-05-31 08:39:22 +08:00
qingwei.li 20d60c401f docs(write-a-plugin): update demo 2017-05-31 08:39:01 +08:00
qingwei.li 1938fd5146 docs(ssr): update 2017-05-31 08:35:01 +08:00
qingwei.li 3b74c49f00 fix(pure-css):add coverpage style, fixed #165 2017-05-31 08:27:11 +08:00
qingwei.li 22b50f07c3 fix: auto replace version 2017-05-31 08:25:00 +08:00
qingwei.li ec887c1b5f fix: update edit button demo 2017-05-30 20:17:17 +08:00
qingwei.li 036fdac131 feat: add edit button demo, close #162 2017-05-30 20:14:31 +08:00
qingwei.li a64cee1236 feat: add edit button demo 2017-05-30 20:12:25 +08:00
42 changed files with 6352 additions and 171 deletions
+25
View File
@@ -1,5 +1,30 @@
# Changelog
4.1.12 / 2017-06-03
* fix(render): ubtitle in side bar shows undefined, fixed [#182](https://github.com/QingWei-Li/docsify/issues/182)
4.1.11 / 2017-06-02
* fix(render): autoHeader does not work
* fix(compiler): force reset toc when rendering sidebar fixed [#181](https://github.com/QingWei-Li/docsify/issues/181)
4.1.10 / 2017-06-02
* fix(hash): hash routing crashes when url has querystring
4.1.9 / 2017-05-31
* fix(lifecycle): continue to handle data
* fix: can't render toc on first load, fixed [#171](https://github.com/QingWei-Li/docsify/issues/171)
* fix(render): broken name link, fixed [#167](https://github.com/QingWei-Li/docsify/issues/167)
## 4.1.8(since 4.1.1) / 2017-05-31
* fix(pure-css):add coverpage style, fixed [#165](https://github.com/QingWei-Li/docsify/issues/165)
* feat: add edit button demo, close [#162](https://github.com/QingWei-Li/docsify/issues/162)
* fix some ssr bugs
## 4.1.0 / 2017-05-30 🎂 to me
+7 -4
View File
@@ -12,6 +12,7 @@
<a href="https://travis-ci.org/QingWei-Li/docsify"><img alt="Travis Status" src="https://img.shields.io/travis/QingWei-Li/docsify/master.svg?style=flat-square"></a>
<a href="https://www.npmjs.com/package/docsify"><img alt="npm" src="https://img.shields.io/npm/v/docsify.svg?style=flat-square"></a>
<a href="https://github.com/QingWei-Li/donate"><img alt="donate" src="https://img.shields.io/badge/%24-donate-ff69b4.svg?style=flat-square"></a>
<a href="https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FQingWei-Li%2Fdocsify?ref=badge_shield" alt="FOSSA Status"><img src="https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FQingWei-Li%2Fdocsify.svg?type=shield"/></a>
</p>
## Links
@@ -22,7 +23,7 @@
## Features
- No statically built html files
- Simple and lightweight (~16kB gzipped)
- Simple and lightweight (~18kB gzipped)
- Smart full-text search plugin
- Multiple themes
- Useful plugin API
@@ -40,12 +41,12 @@ Create an `index.html`.
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/vue.css">
</head>
<body>
<div id="app"></div>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
</body>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
</html>
```
@@ -55,7 +56,7 @@ Modern browsers and Internet Explorer 10+.
## Showcase
These open-source projects are using docsify to generate their sites. Pull requests welcome :blush:
These projects are using docsify to generate their sites. Pull requests welcome :blush:
| Project | Description |
|---|---|
@@ -95,3 +96,5 @@ open http://localhost:3000
## License
MIT
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FQingWei-Li%2Fdocsify.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FQingWei-Li%2Fdocsify?ref=badge_large)
+11
View File
@@ -0,0 +1,11 @@
var fs = require('fs')
var read = fs.readFileSync
var write = fs.writeFileSync
var version = process.env.VERSION || require('../package.json').version
var file = __dirname + '/../docs/_coverpage.md'
var cover = read(file, 'utf8').toString()
console.log('Replace version number in cover page...')
cover = cover.replace(/<small>(\S+)?<\/small>/g, '<small>' + version + '</small>')
write(file, cover)
+4 -1
View File
@@ -1,13 +1,16 @@
var rollup = require('rollup')
var buble = require('rollup-plugin-buble')
var async = require('rollup-plugin-async')
var isProd = process.argv[process.argv.length - 1] !== '--dev'
var replace = require('rollup-plugin-replace')
rollup
.rollup({
entry: 'packages/docsify-server-renderer/index.js',
plugins: [
async(),
replace({
__VERSION__: process.env.VERSION || require('../package.json').version
}),
buble({
transforms: {
generator: false
+6 -1
View File
@@ -4,7 +4,9 @@ var commonjs = require('rollup-plugin-commonjs')
var nodeResolve = require('rollup-plugin-node-resolve')
var string = require('rollup-plugin-string')
var uglify = require('rollup-plugin-uglify')
var replace = require('rollup-plugin-replace')
var isProd = process.argv[process.argv.length - 1] !== '--dev'
var version = process.env.VERSION || require('../package.json').version
var build = function (opts) {
rollup
@@ -14,7 +16,10 @@ var build = function (opts) {
string({ include: '**/*.css' }),
buble(),
commonjs(),
nodeResolve()
nodeResolve(),
replace({
__VERSION__: version
})
])
})
.then(function (bundle) {
+11 -3
View File
@@ -28,15 +28,23 @@
executeScript: true,
loadNavbar: true,
loadSidebar: true,
coverpage: true,
name: 'docsify',
subMaxLevel: 2,
subMaxLevel: 0,
mergeNavbar: true,
formatUpdated: '{MM}/{DD} {HH}:{mm}',
routerMode: 'history',
plugins: [
function(hook) {
function(hook, vm) {
hook.beforeEach(function (html) {
return html += '\n> Last modified {docsify-updated}'
var url = 'https://github.com/QingWei-Li/docsify/blob/master' + vm.router.getFile()
var editHtml = '[:memo: Edit Document](' + url + ')\n'
return editHtml
+ html
+ '\n----\n'
+ 'Last modified {docsify-updated} '
+ editHtml
})
}
]
+2 -1
View File
@@ -11,12 +11,13 @@ See the [Quick start](quickstart.md) for more details.
## Features
* No statically built html files
* Simple and lightweight (~16kB gzipped)
* Simple and lightweight (~18kB gzipped)
* Smart full-text search plugin
* Multiple themes
* Useful plugin API
* Emoji support
* Compatible with IE10+
- Support SSR ([example](https://github.com/QingWei-Li/docsify-ssr-demo))
## Examples
+2 -2
View File
@@ -1,10 +1,10 @@
![logo](_media/icon.svg)
# docsify <small>4.0</small>
# docsify <small>4.1.12</small>
> A magical documentation site generator.
- Simple and lightweight (~16kB gzipped)
- Simple and lightweight (~18kB gzipped)
- No statically built html files
- Multiple themes
+1 -1
View File
@@ -45,6 +45,6 @@ Alternatively, use [compressed files](#compressed-files).
## Other CDN
- http://www.bootcdn.cn/docsify
- http://www.jsdelivr.com/projects/docsify
- https://cdn.jsdelivr.net/npm/docsify/
- https://cdnjs.com/libraries/docsify
+1 -1
View File
@@ -26,7 +26,7 @@ Set `coverpage` to **true**, and create a `_coverpage.md`:
> A magical documentation site generator.
- Simple and lightweight (~16kB gzipped)
- Simple and lightweight (~18kB gzipped)
- No statically built html files
- Multiple themes
+2 -1
View File
@@ -11,12 +11,13 @@ Siehe [Schnellstart](de-de/quickstart.md) für weitere Informationen.
## Features
* keine generierten, statischen HTML Dateien
* einfach und klein (~16kB gzipped)
* einfach und klein (~18kB gzipped)
* smarte Erweiterung mit Volltextsuche
* mehrere Themes
* praktische API für Erweiterungen
* Unterstützung für Emoji
* Kompatibel mit IE10+
- Support SSR ([example](https://github.com/QingWei-Li/docsify-ssr-demo))
## Beispiele
+1 -1
View File
@@ -45,5 +45,5 @@ Alternativ kannst du auch die [komprimierten Dateien](#komprimierte-dateien) ver
## Andere CDN
- http://www.bootcdn.cn/docsify
- http://www.jsdelivr.com/projects/docsify
- https://cdn.jsdelivr.net/npm/docsify/
- https://cdnjs.com/libraries/docsify
+1 -1
View File
@@ -26,7 +26,7 @@ Setze `coverpage` auf **true**, und erstelle `_coverpage.md`:
> Ein magischer Generator für Dokumentationsseiten.
- Einfach und wenig Speicherbedarf (~16kB gzipped)
- Einfach und wenig Speicherbedarf (~18kB gzipped)
- Keine statischen HTML Dateien
- Mehrere Themes
+8 -9
View File
@@ -2,6 +2,8 @@
See https://docsify.now.sh
Repo in https://github.com/QingWei-Li/docsify-ssr-demo
## Why SSR?
- Better SEO
- Feeling cool
@@ -11,24 +13,24 @@ See https://docsify.now.sh
Install `now` and `docsify-cli` in your project.
```bash
npm i now -g
npm i docsify-cli -D
npm i now docsify-cli -D
```
Edit `package.json`. If the documentation in `./docs` subdirectory.
Edit `package.json`. If the documentation in `./docs` subdirectory.
```json
{
"name": "my-project",
"scripts": {
"start": "docsify start ."
"start": "docsify start . -c ssr.config.js",
"deploy": "now -p"
},
"files": [
"docs"
],
"docsify": {
"config": {
"basePath": "/docs/",
"basePath": 'https://docsify.js.org/',
"loadSidebar": true,
"loadNavbar": true,
"coverpage": true,
@@ -38,10 +40,7 @@ npm i docsify-cli -D
}
```
Remove `index.html`
!> The `basePath` just like webpack `publicPath`. You should config it if your docs is in the subdirectory.
!> The `basePath` just like webpack `publicPath`. We can use local or remote files.
We can preview in the local to see if it works.
+24
View File
@@ -47,6 +47,8 @@ window.$docsify = {
## Beispiel
### footer
Füge jeder Seite eine footer Komponente hinzu:
```js
@@ -68,3 +70,25 @@ window.$docsify = {
]
}
```
### Edit Button
```js
window.$docsify = {
plugins: [
function(hook, vm) {
hook.beforeEach(function (html) {
var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs' + vm.route.file
var editHtml = '[📝 EDIT DOCUMENT](' + url + ')\n'
return editHtml
+ html
+ '\n----\n'
+ 'Last modified {docsify-updated} '
+ editHtml
})
}
]
}
```
+18 -11
View File
@@ -7,10 +7,10 @@
<meta name="keywords" content="doc,docs,documentation,gitbook,creator,generator,github,jekyll,github-pages">
<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="//unpkg.com/docsify/lib/themes/vue.css" title="vue">
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/dark.css" title="dark" disabled>
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/buble.css" title="buble" disabled>
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/pure.css" title="pure" disabled>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@latest/lib/themes/vue.css" title="vue">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@latest/lib/themes/dark.css" title="dark" disabled>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@latest/lib/themes/buble.css" title="buble" disabled>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@latest/lib/themes/pure.css" title="pure" disabled>
<style>
nav.app-nav li ul {
min-width: 100px;
@@ -51,17 +51,24 @@
},
formatUpdated: '{MM}/{DD} {HH}:{mm}',
plugins: [
function(hook) {
function(hook, vm) {
hook.beforeEach(function (html) {
return html += '\n> Last modified {docsify-updated}'
var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs' + vm.route.file
var editHtml = '[:memo: Edit Document](' + url + ')\n'
return editHtml
+ html
+ '\n----\n'
+ 'Last modified {docsify-updated} '
+ editHtml
})
}
]
}
</script>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-nginx.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify@latest/lib/docsify.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify@latest/lib/plugins/search.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-markdown.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-nginx.min.js"></script>
</html>
+7 -7
View File
@@ -2,6 +2,8 @@
See https://docsify.now.sh
Repo in https://github.com/QingWei-Li/docsify-ssr-demo
## Why SSR?
- Better SEO
- Feeling cool
@@ -11,8 +13,7 @@ See https://docsify.now.sh
Install `now` and `docsify-cli` in your project.
```bash
npm i now -g
npm i docsify-cli -D
npm i now docsify-cli -D
```
Edit `package.json`. If the documentation in `./docs` subdirectory.
@@ -21,14 +22,15 @@ Edit `package.json`. If the documentation in `./docs` subdirectory.
{
"name": "my-project",
"scripts": {
"start": "docsify start ."
"start": "docsify start . -c ssr.config.js",
"deploy": "now -p"
},
"files": [
"docs"
],
"docsify": {
"config": {
"basePath": "/docs/",
"basePath": 'https://docsify.js.org/',
"loadSidebar": true,
"loadNavbar": true,
"coverpage": true,
@@ -38,9 +40,7 @@ Edit `package.json`. If the documentation in `./docs` subdirectory.
}
```
Remove `index.html`
!> The `basePath` just like webpack `publicPath`. You should config it if your docs is in the subdirectory.
!> The `basePath` just like webpack `publicPath`. We can use local or remote files.
We can preview in the local to see if it works.
+23
View File
@@ -47,6 +47,8 @@ window.$docsify = {
## Example
#### footer
Add footer component in each pages.
```js
@@ -68,3 +70,24 @@ window.$docsify = {
]
}
```
### Edit Button
```js
window.$docsify = {
plugins: [
function(hook, vm) {
hook.beforeEach(function (html) {
var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs' + vm.route.file
var editHtml = '[📝 EDIT DOCUMENT](' + url + ')\n'
return editHtml
+ html
+ '\n----\n'
+ 'Last modified {docsify-updated} '
+ editHtml
})
}
]
}
```
+2 -1
View File
@@ -12,12 +12,13 @@ docsify 是一个动态生成文档网站的工具。不同于 GitBook、Hexo
## 特性
- 无需构建,写完文档直接发布
- 容易使用并且轻量 (~16kB gzipped)
- 容易使用并且轻量 (~18kB gzipped)
- 智能的全文搜索
- 提供多套主题
- 丰富的 API
- 支持 Emoji
- 兼容 IE10+
- 支持 SSR ([example](https://github.com/QingWei-Li/docsify-ssr-demo))
## 例子
+2 -2
View File
@@ -44,6 +44,6 @@ JS 的压缩文件是原有文件路径的基础上加 `.min`后缀
## 其他 CDN
- http://www.bootcdn.cn/docsify
- http://www.jsdelivr.com/projects/docsify
- http://www.bootcdn.cn/docsify (支持国内)
- https://cdn.jsdelivr.net/npm/docsify/ (国内外都支持)
- https://cdnjs.com/libraries/docsify
+1 -1
View File
@@ -8,4 +8,4 @@
<script src="//unpkg.com/prismjs/components/prism-php.js"></script>
```
?> 其他的语言高亮插件可以查看[Prims 仓库](https://github.com/PrismJS/prism/tree/gh-pages/components)。
?> 其他的语言高亮插件可以查看[Prims 仓库](https://github.com/PrismJS/prism/tree/gh-pages/components)。
+52 -58
View File
@@ -1,67 +1,61 @@
# Server client renderer
# 服务端渲染(SSR
See https://docsify.now.sh
先看例子 https://docsify.now.sh
## Why SSR?
- Better SEO
- Feeling cool
项目地址在 https://github.com/QingWei-Li/docsify-ssr-demo
## Quick start
![](https://dn-mhke0kuv.qbox.me/2bfef08c592706108055.png)
Install `now` and `docsify-cli` in your project.
文档依旧是部署在 GitHub Pages 上,Node 服务部署在 now.sh 里,渲染的内容是从 GitHub Pages 上同步过来的。所以静态部署文档的服务器和服务端渲染的 Node 服务器是分开的,也就是说你还是可以用之前的方式更新文档,并不需要每次都部署。
## 快速开始
如果你熟悉 `now` 的使用,接下来的介绍就很简单了。先创建一个新项目,并安装 `now``docsify-cli`
```bash
npm i now -g
npm i docsify-cli -D
mkdir my-ssr-demo && cd my-ssr-demo
npm init -y
npm i now docsify-cli -D
```
2. Edit `package.json`. If the documentation in `./docs` subdirectory.
配置 `package.json`
```json
{
"name": "my-project",
"scripts": {
"start": "docsify start ."
"start": "docsify start .",
"deploy": "now -p"
},
"files": [
"docs"
],
"docsify": {
"config": {
"basePath": "/docs/",
"basePath": "https://docsify.js.org/",
"loadSidebar": true,
"loadNavbar": true,
"coverpage": true,
"name": "docsify"
"loadNavbar": true
}
}
}
```
如果你还没有创建文档,可以参考[之前的文章](https://zhuanlan.zhihu.com/p/24540753)。其中 `basePath` 为文档所在的路径,可以填你的 docsify 文档网站。
Remove `index.html`
配置可以单独写在配置文件内,然后通过 `--config config.js` 加载。
!> The `basePath` just like webpack `publicPath`. You should config it if your docs is in the subdirectory.
渲染的基础模版也可以自定义,配置在 `template` 属性上,例如
We can preview in the local to see if it works.
```bash
npm start
# open http://localhost:4000
```js
"docsify": {
"template": "./ssr.html",
"config": {
"basePath": "https://docsify.js.org/",
"loadSidebar": true,
"loadNavbar": true
}
}
```
Publish it!
```bash
now -p
```
Now, You have a support for SSR the docs site.
## Custom template
You can provide a templte for entire page's HTML. such as
*ssr.html*
```html
<!DOCTYPE html>
@@ -69,41 +63,39 @@ You can provide a templte for entire page's HTML. such as
<head>
<meta charset="UTF-8">
<title>docsify</title>
<link rel="icon" href="_media/favicon.ico">
<meta name="keywords" content="doc,docs,documentation,gitbook,creator,generator,github,jekyll,github-pages">
<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="//unpkg.com/docsify/themes/vue.css" title="vue">
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css" title="vue">
</head>
<body>
<!--inject-app-->
<!--inject-config-->
</body>
<script src="//unpkg.com/docsify/lib/docsify.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.js"></script>
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-nginx.min.js"></script>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
</html>
```
The template should contain these comments for rendered app content.
- `<!--inject-app-->`
- `<!--inject-config-->`
其中 `<!--inject-app-->``<!--inject-config-->` 为占位符,会自动将渲染后的 html 和配置内容注入到页面上。
## Configuration
现在,你可以运行 `npm start` 预览效果,如果没有问题就通过 `npm run deploy` 部署服务。
You can configure it in a special config file, or `package.json`.
```bash
npm start
# open http://localhost:4000
```js
module.exports = {
template: './ssr.html',
config: {
// docsify config
}
}
npm run deploy
# now ...
```
## Deploy for your VPS
You can run `docsify start` directly on your Node server, or write your own server app with `docsify-server-renderer`.
## 更多玩法
`docsify start` 其实是依赖了 [`docsify-server-renderer`](https://npmarket.surge.sh/?name=docsify-server-renderer) 模块,如果你感兴趣,你完全可以用它自己实现一个 server,可以加入缓存等功能。
```js
var Renderer = require('docsify-server-renderer')
@@ -122,3 +114,5 @@ renderer.renderToString(url)
.then(html => {})
.catch(err => {})
```
当然文档文件和 server 也是可以部署在一起的,`basePath` 不是一个 URL 的话就会当做文件路径处理,也就是从服务器上加载资源。
+25
View File
@@ -46,6 +46,9 @@ window.$docsify = {
## 例子
### footer
给每个页面的末尾加上 `footer`
```js
@@ -66,4 +69,26 @@ window.$docsify = {
}
]
}
```
### Edit Button
```js
window.$docsify = {
plugins: [
function(hook, vm) {
hook.beforeEach(function (html) {
var url = 'https://github.com/QingWei-Li/docsify/blob/master/docs' + vm.route.file
var editHtml = '[📝 EDIT DOCUMENT](' + url + ')\n'
return editHtml
+ html
+ '\n----\n'
+ 'Last modified {docsify-updated} '
+ editHtml
})
}
]
}
```
+7
View File
@@ -0,0 +1,7 @@
{
"lerna": "2.0.0-rc.5",
"packages": [
"packages/*"
],
"version": "0.0.0"
}
+25 -14
View File
@@ -126,23 +126,22 @@ function initLifecycle (vm) {
function callHook (vm, hook, data, next) {
if ( next === void 0 ) next = noop;
var newData = data;
var queue = vm._hooks[hook];
var step = function (index) {
var hook = queue[index];
if (index >= queue.length) {
next(newData);
next(data);
} else {
if (typeof hook === 'function') {
if (hook.length === 2) {
hook(data, function (result) {
newData = result;
data = result;
step(index + 1);
});
} else {
var result = hook(data);
newData = result !== undefined ? result : newData;
data = result !== undefined ? result : data;
step(index + 1);
}
} else {
@@ -2797,8 +2796,8 @@ Compiler.prototype._initRenderer = function _initRenderer () {
var ref = this;
var linkTarget = ref.linkTarget;
var router = ref.router;
var toc = ref.toc;
var contentBase = ref.contentBase;
var _self = this;
/**
* render anchor tag
* @link https://github.com/chjj/marked#overriding-renderer-methods
@@ -2821,7 +2820,7 @@ Compiler.prototype._initRenderer = function _initRenderer () {
var slug = slugify(text);
var url = router.toURL(router.getCurrentPath(), { id: slug });
nextToc.slug = url;
toc.push(nextToc);
_self.toc.push(nextToc);
return ("<h" + level + " id=\"" + slug + "\"><a href=\"" + url + "\" data-id=\"" + slug + "\" class=\"anchor\"><span>" + text + "</span></a></h" + level + ">")
};
@@ -2890,6 +2889,10 @@ Compiler.prototype.sidebar = function sidebar (text, level) {
* Compile sub sidebar
*/
Compiler.prototype.subSidebar = function subSidebar (level) {
if (!level) {
this.toc = [];
return
}
var currentPath = this.router.getCurrentPath();
var ref = this;
var cacheTree = ref.cacheTree;
@@ -3159,10 +3162,13 @@ function renderMixin (proto) {
this._renderTo('.sidebar-nav', this.compiler.sidebar(text, maxLevel));
var activeEl = getAndActive(this.router, '.sidebar-nav', true, true);
if (loadSidebar && activeEl) {
activeEl.parentNode.innerHTML += this.compiler.subSidebar(subMaxLevel);
activeEl.parentNode.innerHTML += (this.compiler.subSidebar(subMaxLevel) || '');
} else {
// reset toc
this.compiler.subSidebar();
}
// bind event
this._bindEventOnRendered();
this._bindEventOnRendered(activeEl);
};
proto._bindEventOnRendered = function (activeEl) {
@@ -3288,6 +3294,7 @@ function initRender (vm) {
// Polyfll
cssVars(config.themeColor);
}
vm._updateRender();
toggleClass(body, 'ready');
}
@@ -3403,17 +3410,17 @@ var HashHistory = (function (History$$1) {
var query = '';
var hashIndex = path.indexOf('#');
if (hashIndex) {
path = path.slice(hashIndex + 1);
}
var queryIndex = path.indexOf('?');
if (queryIndex >= 0) {
query = path.slice(queryIndex + 1);
path = path.slice(0, queryIndex);
}
var hashIndex = path.indexOf('#');
if (hashIndex) {
path = path.slice(hashIndex + 1);
}
return {
path: path,
file: this.getFile(path),
@@ -3544,7 +3551,6 @@ function initRouter (vm) {
router.normalize();
lastRoute = vm.route = router.parse();
vm._updateRender();
router.onchange(function (_) {
router.normalize();
@@ -3741,6 +3747,11 @@ eventMixin(proto);
*/
initGlobalAPI();
/**
* Version
*/
Docsify.version = '4.1.12';
/**
* Run Docsify
*/
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -498,6 +498,6 @@ var install = function (hook, vm) {
});
};
window.$docsify.plugins = [].concat(install, window.$docsify.plugins);
$docsify.plugins = [].concat(install, $docsify.plugins);
}());
+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
+4933
View File
File diff suppressed because it is too large Load Diff
+5 -2
View File
@@ -1,6 +1,6 @@
{
"name": "docsify",
"version": "4.1.7",
"version": "4.1.12",
"description": "A magical documentation generator.",
"author": {
"name": "qingwei-li",
@@ -20,7 +20,8 @@
"themes"
],
"scripts": {
"build": "rm -rf lib themes && node build/build && mkdir lib/themes && mkdir themes && node build/build-css && npm run build:ssr",
"bootstrap": "npm i && lerna bootstrap",
"build": "rm -rf lib themes && node build/build && mkdir lib/themes && mkdir themes && node build/build-css && npm run build:ssr && node build/build-cover",
"dev:build": "rm -rf lib themes && mkdir themes && node build/build --dev && node build/build-css --dev",
"dev": "node app & nodemon -w src -e js,css --exec 'npm run dev:build'",
"build:ssr": "node build/build-ssr",
@@ -39,6 +40,7 @@
"eslint": "^3.18.0",
"eslint-config-vue": "^2.0.2",
"eslint-plugin-vue": "^2.0.1",
"lerna": "^2.0.0-rc.5",
"nodemon": "^1.11.0",
"postcss": "^5.2.16",
"postcss-salad": "^1.0.8",
@@ -47,6 +49,7 @@
"rollup-plugin-buble": "^0.15.0",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-plugin-string": "^2.0.2",
"rollup-plugin-uglify": "^1.0.1",
"serve-static": "^1.12.1"
@@ -139,3 +139,5 @@ export default class Renderer {
}
}
}
Renderer.version = '__VERSION__'
@@ -1,6 +1,6 @@
{
"name": "docsify-server-renderer",
"version": "4.1.7",
"version": "4.1.12",
"description": "docsify server renderer",
"author": {
"name": "qingwei-li",
+5
View File
@@ -22,6 +22,11 @@ eventMixin(proto)
*/
initGlobalAPI()
/**
* Version
*/
Docsify.version = '__VERSION__'
/**
* Run Docsify
*/
+3 -4
View File
@@ -19,23 +19,22 @@ export function initLifecycle (vm) {
}
export function callHook (vm, hook, data, next = noop) {
let newData = data
const queue = vm._hooks[hook]
const step = function (index) {
const hook = queue[index]
if (index >= queue.length) {
next(newData)
next(data)
} else {
if (typeof hook === 'function') {
if (hook.length === 2) {
hook(data, result => {
newData = result
data = result
step(index + 1)
})
} else {
const result = hook(data)
newData = result !== undefined ? result : newData
data = result !== undefined ? result : data
step(index + 1)
}
} else {
+7 -2
View File
@@ -44,7 +44,8 @@ export class Compiler {
_initRenderer () {
const renderer = new marked.Renderer()
const { linkTarget, router, toc, contentBase } = this
const { linkTarget, router, contentBase } = this
const _self = this
/**
* render anchor tag
* @link https://github.com/chjj/marked#overriding-renderer-methods
@@ -67,7 +68,7 @@ export class Compiler {
const slug = slugify(text)
const url = router.toURL(router.getCurrentPath(), { id: slug })
nextToc.slug = url
toc.push(nextToc)
_self.toc.push(nextToc)
return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${text}</span></a></h${level}>`
}
@@ -134,6 +135,10 @@ export class Compiler {
* Compile sub sidebar
*/
subSidebar (level) {
if (!level) {
this.toc = []
return
}
const currentPath = this.router.getCurrentPath()
const { cacheTree, toc } = this
+6 -2
View File
@@ -84,10 +84,13 @@ export function renderMixin (proto) {
this._renderTo('.sidebar-nav', this.compiler.sidebar(text, maxLevel))
const activeEl = getAndActive(this.router, '.sidebar-nav', true, true)
if (loadSidebar && activeEl) {
activeEl.parentNode.innerHTML += this.compiler.subSidebar(subMaxLevel)
activeEl.parentNode.innerHTML += (this.compiler.subSidebar(subMaxLevel) || '')
} else {
// reset toc
this.compiler.subSidebar()
}
// bind event
this._bindEventOnRendered()
this._bindEventOnRendered(activeEl)
}
proto._bindEventOnRendered = function (activeEl) {
@@ -208,5 +211,6 @@ export function initRender (vm) {
// Polyfll
cssVars(config.themeColor)
}
vm._updateRender()
dom.toggleClass(dom.body, 'ready')
}
+5 -5
View File
@@ -58,17 +58,17 @@ export class HashHistory extends History {
parse (path = location.href) {
let query = ''
const hashIndex = path.indexOf('#')
if (hashIndex) {
path = path.slice(hashIndex + 1)
}
const queryIndex = path.indexOf('?')
if (queryIndex >= 0) {
query = path.slice(queryIndex + 1)
path = path.slice(0, queryIndex)
}
const hashIndex = path.indexOf('#')
if (hashIndex) {
path = path.slice(hashIndex + 1)
}
return {
path,
file: this.getFile(path),
-1
View File
@@ -23,7 +23,6 @@ export function initRouter (vm) {
router.normalize()
lastRoute = vm.route = router.parse()
vm._updateRender()
router.onchange(_ => {
router.normalize()
+1 -1
View File
@@ -10,4 +10,4 @@ const install = function (hook, vm) {
})
}
window.$docsify.plugins = [].concat(install, window.$docsify.plugins)
$docsify.plugins = [].concat(install, $docsify.plugins)
+1
View File
@@ -3,3 +3,4 @@ $color-bg: #fff;
$color-text: #000;
$sidebar-width: 300px;
@import "basic/layout";
@import "basic/coverpage";
+1110 -28
View File
File diff suppressed because it is too large Load Diff