mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-26 05:36:13 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5efa763075 | ||
|
|
03a04f7898 | ||
|
|
a88252c6b2 | ||
|
|
2f5f90750a | ||
|
|
709c152950 | ||
|
|
b09a5a317e | ||
|
|
628e2115a3 | ||
|
|
271dde8f5e | ||
|
|
1fa1619278 | ||
|
|
3de3def8a8 | ||
|
|
fb25726426 | ||
|
|
36ddc42e91 | ||
|
|
abb0f6019f | ||
|
|
b8dd346baf | ||
|
|
7191d702e1 | ||
|
|
c039f1bfc0 | ||
|
|
f859d2d0b2 | ||
|
|
9735f4036e | ||
|
|
b8a96b867b | ||
|
|
b7b589b1bf | ||
|
|
761e38f6ad | ||
|
|
78899a0251 | ||
|
|
357631c8b7 | ||
|
|
17ff3d1506 | ||
|
|
f59aac478a | ||
|
|
0dd2497467 | ||
|
|
306136f6a3 | ||
|
|
4aba9d0a25 | ||
|
|
3d2f23bcdc | ||
|
|
b85eb0ff4b | ||
|
|
efa8d25912 | ||
|
|
437737cc5a | ||
|
|
992ff77808 | ||
|
|
4cf13db685 | ||
|
|
e54062f80d | ||
|
|
cee8ac6698 | ||
|
|
d057f66fce | ||
|
|
9b0f1978a4 | ||
|
|
d9848c3384 | ||
|
|
4dabae3bf2 | ||
|
|
b430993f4f | ||
|
|
2e00f4c993 | ||
|
|
7fb5ce6c84 | ||
|
|
c4aa22c56d | ||
|
|
9af855921e | ||
|
|
4492c3e19f | ||
|
|
f598e53098 | ||
|
|
4bde6d685c | ||
|
|
ce0e9acd50 | ||
|
|
e8117e515d | ||
|
|
25e09dfe07 | ||
|
|
a6b46a3e26 | ||
|
|
d469442eae | ||
|
|
9f310bbd7d | ||
|
|
cc8a7c97b6 | ||
|
|
19da658ba2 | ||
|
|
97db30a0b9 | ||
|
|
3a0765e11e | ||
|
|
aaf71b1ac0 | ||
|
|
b37781e949 | ||
|
|
54a48dd3ff | ||
|
|
1aabc41db7 | ||
|
|
d087d5753b | ||
|
|
bb793ec08e | ||
|
|
6a78ae7ddc | ||
|
|
ac28040bd7 | ||
|
|
b12f74b159 | ||
|
|
1304d2ea1a | ||
|
|
ccf4c7c5cc | ||
|
|
9b15d8d577 | ||
|
|
642e7da7ee | ||
|
|
75381cf046 | ||
|
|
7e2e5a7c90 | ||
|
|
6d48ce1266 | ||
|
|
d286963da0 | ||
|
|
8a4cedd962 | ||
|
|
a3b7b66a76 | ||
|
|
5a0d4b7897 | ||
|
|
fcfdb17b8d | ||
|
|
e4d2e7ec12 | ||
|
|
ece00e6b3a | ||
|
|
841829427b | ||
|
|
56c7b9ae2d | ||
|
|
db8400a6ac | ||
|
|
955d3d5988 | ||
|
|
d9b487e67b | ||
|
|
91b66a5cac | ||
|
|
90bba60367 | ||
|
|
d05c4f65a8 | ||
|
|
3380a62142 | ||
|
|
8e418a1681 | ||
|
|
20d60c401f | ||
|
|
1938fd5146 | ||
|
|
3b74c49f00 | ||
|
|
22b50f07c3 | ||
|
|
ec887c1b5f | ||
|
|
036fdac131 | ||
|
|
a64cee1236 | ||
|
|
f943fede99 | ||
|
|
e296439df3 | ||
|
|
0014895c19 | ||
|
|
23590fa7e7 | ||
|
|
8689a37121 | ||
|
|
05a0211861 | ||
|
|
318189a13f | ||
|
|
42795a0483 | ||
|
|
6b9e0922cf | ||
|
|
8cb4189b96 | ||
|
|
7eb6346075 | ||
|
|
238e9633f9 | ||
|
|
6db8c9e6c9 | ||
|
|
e160bcaded | ||
|
|
8cf69754b5 | ||
|
|
79a83bc17d | ||
|
|
81c87f7926 | ||
|
|
67ec128315 | ||
|
|
77657e3b64 | ||
|
|
9825db47af | ||
|
|
1a5593889e | ||
|
|
fc9cdf37c5 | ||
|
|
80dba191d3 | ||
|
|
5a0c37fcd3 | ||
|
|
1462efedcd | ||
|
|
4cb20a5f9d | ||
|
|
490c8a19d3 | ||
|
|
4b838247ea | ||
|
|
b091f3f10d | ||
|
|
0e74e6c15e | ||
|
|
be8358fcdc | ||
|
|
1ae0a9a845 | ||
|
|
7e169ad154 | ||
|
|
8595c99c0b | ||
|
|
43fc8b8ab1 | ||
|
|
ccec23df7f | ||
|
|
fc1cd3f11d | ||
|
|
3f38810774 | ||
|
|
3db4841da3 | ||
|
|
b764b6e32c | ||
|
|
46261572e3 | ||
|
|
d53b8dadb3 | ||
|
|
b9b9d87681 | ||
|
|
d4f6072d10 | ||
|
|
891475e132 | ||
|
|
1acfdd335c | ||
|
|
1f4514dcad | ||
|
|
eba1c987a8 | ||
|
|
3444884905 | ||
|
|
6dea685fee | ||
|
|
f095eb888f | ||
|
|
8741c746df | ||
|
|
2c7041c8fb | ||
|
|
2a21c40f17 | ||
|
|
000194c8da | ||
|
|
fce1e47131 | ||
|
|
6d244139dd | ||
|
|
eca3368152 | ||
|
|
bab76e004d | ||
|
|
eb9dc4671a | ||
|
|
bb815cb2d4 | ||
|
|
26db33dc31 | ||
|
|
6cbed4b4d8 | ||
|
|
b948cb06d7 | ||
|
|
b2b474264f | ||
|
|
a8c73ee2b9 | ||
|
|
eda9bb8343 | ||
|
|
50e771e6a8 | ||
|
|
2d73285de5 | ||
|
|
d2be5aecf8 | ||
|
|
ca0d6182b9 | ||
|
|
dacea8a39b | ||
|
|
da75d70dee | ||
|
|
6ed25cebe5 | ||
|
|
ee54141776 | ||
|
|
51832d3506 | ||
|
|
25ccc79e56 | ||
|
|
890d29f982 | ||
|
|
76c041ad48 | ||
|
|
2c277b8f79 | ||
|
|
a5f6ccd1d1 | ||
|
|
11c94b2149 | ||
|
|
2653849a3e | ||
|
|
d7b0d1b949 | ||
|
|
6911fb879b | ||
|
|
137a93c7b2 | ||
|
|
5d5caa1f89 | ||
|
|
1dfd6cdcfe | ||
|
|
91c6db2902 | ||
|
|
94d6603c06 | ||
|
|
920f624b5c | ||
|
|
8fb1350728 | ||
|
|
c1df94662a | ||
|
|
9b7e5f5814 | ||
|
|
432bcfb54b | ||
|
|
4f98497284 | ||
|
|
9220523a40 | ||
|
|
b8100c0755 | ||
|
|
be0230ebe9 | ||
|
|
aa6d2afce8 | ||
|
|
a706203879 | ||
|
|
fbc75bdb95 | ||
|
|
5af174bd20 | ||
|
|
e70327ab2b | ||
|
|
7209b82982 | ||
|
|
594299ffbd | ||
|
|
e9bbfd4c53 | ||
|
|
96bc09211e | ||
|
|
8f11653b41 | ||
|
|
6aae64fd54 | ||
|
|
33b7c512bb | ||
|
|
bf35471a2b | ||
|
|
b022aaf14e | ||
|
|
03d8281868 | ||
|
|
4a0cfa799e |
@@ -0,0 +1,3 @@
|
|||||||
|
.git/
|
||||||
|
packages/docsify-server-renderer/build.js
|
||||||
|
node_modules
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
{
|
{
|
||||||
"extends": ["vue"],
|
"extends": [
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 8
|
||||||
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true
|
"browser": true
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
.DS_Store
|
|
||||||
*.log
|
*.log
|
||||||
|
.DS_Store
|
||||||
|
/themes
|
||||||
node_modules
|
node_modules
|
||||||
/themes
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
.eslintignore
|
||||||
|
.eslintrc
|
||||||
|
.github/
|
||||||
|
.gitignore
|
||||||
|
.travis.yml
|
||||||
+4
-1
@@ -1,6 +1,9 @@
|
|||||||
sudo: false
|
sudo: false
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.yarn-cache
|
- $HOME/.yarn-cache
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js: stable
|
node_js: stable
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- osx
|
||||||
|
|||||||
+232
-59
@@ -1,94 +1,267 @@
|
|||||||
|
<a name="4.2.7"></a>
|
||||||
|
## [4.2.7](https://github.com/QingWei-Li/docsify/compare/v4.2.4...v4.2.7) (2017-08-05)
|
||||||
|
|
||||||
# 3.4.4 / 2017-03-17
|
|
||||||
|
|
||||||
* fix(search): fix input style
|
### Bug Fixes
|
||||||
* fix search plugin match bug
|
|
||||||
|
|
||||||
# 3.4.3 / 2017-03-16
|
* **css:** hide the nav when the content has not yet been loaded ([1fa1619](https://github.com/QingWei-Li/docsify/commit/1fa1619))
|
||||||
|
* **release:** release shell ([628e211](https://github.com/QingWei-Li/docsify/commit/628e211))
|
||||||
|
* **style:** nowrap => pre-wrap, fixed [#228](https://github.com/QingWei-Li/docsify/issues/228) ([a88252c](https://github.com/QingWei-Li/docsify/commit/a88252c))
|
||||||
|
|
||||||
* Add ability to ignore headers when generating toc ([#127](https://github.com/QingWei-Li/docsify/issues/127) [@christopherwk210](https://github.com/christopherwk210))
|
|
||||||
* fix external-script not inserting script at right place [@Leopoldthecoder](https://github.com/Leopoldthecoder)
|
|
||||||
* add German docs [@jrappen](https://github.com/jrappen)
|
|
||||||
|
|
||||||
# 3.4.2 / 2017-03-11
|
|
||||||
|
|
||||||
* feat(emojify): add no-emoji option
|
<a name="4.2.6"></a>
|
||||||
|
## [4.2.6](https://github.com/QingWei-Li/docsify/compare/v4.2.4...v4.2.6) (2017-07-27)
|
||||||
|
|
||||||
# 3.4.1 / 2017-03-10
|
|
||||||
|
|
||||||
* fix(dom): Disable the dom cache when vue is present, fixed [#119](https://github.com/QingWei-Li/docsify/issues/119)
|
### Bug Fixes
|
||||||
* update english docs, [@jrappen](https://github.com/jrappen)
|
|
||||||
|
|
||||||
# 3.4.0 / 2017-03-09
|
* **css:** hide the nav when the content has not yet been loaded ([1fa1619](https://github.com/QingWei-Li/docsify/commit/1fa1619))
|
||||||
|
* **release:** release shell ([628e211](https://github.com/QingWei-Li/docsify/commit/628e211))
|
||||||
|
|
||||||
* feat(zoom-image): add plugin
|
|
||||||
|
|
||||||
# 3.3.0 / 2017-03-07
|
|
||||||
|
|
||||||
* add front-matter plugin
|
<a name="4.2.4"></a>
|
||||||
* add external-script plugin, [@Leopoldthecoder](https://github.com/Leopoldthecoder)
|
## [4.2.4](https://github.com/QingWei-Li/docsify/compare/v4.2.2...v4.2.4) (2017-07-26)
|
||||||
* Fix nav showing while loading ([#112](https://github.com/QingWei-Li/docsify/issues/112))
|
|
||||||
|
|
||||||
# 3.2.0 / 2017-02-28
|
|
||||||
|
|
||||||
* fix(render): Toc rendering error, fixed [#106](https://github.com/QingWei-Li/docsify/issues/106)
|
### Bug Fixes
|
||||||
* feat(search): Localization for no data tip, close [#103](https://github.com/QingWei-Li/docsify/issues/103)
|
|
||||||
* fix(fetch): load sidebar and navbar for parent path, fixed [#100](https://github.com/QingWei-Li/docsify/issues/100)
|
|
||||||
* feat(render) nameLink for each route, fixed [#99](https://github.com/QingWei-Li/docsify/issues/99)
|
|
||||||
|
|
||||||
# 3.1.2 / 2017-02-27
|
* **render:** Remove getRootNode to be compatible with the lower version of Chrome, fixed [#225](https://github.com/QingWei-Li/docsify/issues/225) ([b8dd346](https://github.com/QingWei-Li/docsify/commit/b8dd346))
|
||||||
|
|
||||||
* fix(search): dont search nameLink, fixed [#102](https://github.com/QingWei-Li/docsify/issues/102)
|
<a name="4.2.3"></a>
|
||||||
|
## [4.2.3](https://github.com/QingWei-Li/docsify/compare/v4.2.2...v4.2.3) (2017-07-26)
|
||||||
|
|
||||||
# 3.1.1 / 2017-02-24
|
|
||||||
|
|
||||||
* fix(search): dont search nameLink, fixed [#102](https://github.com/QingWei-Li/docsify/issues/102)
|
### Features
|
||||||
* fix(render): custom cover background image
|
|
||||||
* fix(tpl): extra character, fixed [#101](https://github.com/QingWei-Li/docsify/issues/101)
|
|
||||||
|
|
||||||
# 3.1.0 / 2017-02-22
|
* **search:** Supports the max depth of the search headline, fixed [#223](https://github.com/QingWei-Li/docsify/issues/223), resolve [#129](https://github.com/QingWei-Li/docsify/issues/129) ([b7b589b](https://github.com/QingWei-Li/docsify/commit/b7b589b))
|
||||||
|
|
||||||
* fix(search): incorrect anchor link, fixed [#90](https://github.com/QingWei-Li/docsify/issues/90)
|
|
||||||
* feat(emoji): add emoji plugin
|
|
||||||
|
|
||||||
# 3.0.5 / 2017-02-21
|
|
||||||
|
|
||||||
* feat(pwa): add sw.js
|
<a name="4.2.2"></a>
|
||||||
* fix(layout.css): loading style
|
## [4.2.2](https://github.com/QingWei-Li/docsify/compare/v4.2.1...v4.2.2) (2017-07-24)
|
||||||
* fix(event): highlight sidebar when clicked, fixed [#86](https://github.com/QingWei-Li/docsify/issues/86)
|
|
||||||
* fix(gen-tree): cache toc list, fixed [#88](https://github.com/QingWei-Li/docsify/issues/88)
|
|
||||||
|
|
||||||
# 3.0.4 / 2017-02-20
|
|
||||||
|
|
||||||
* fix(render): execute script
|
### Bug Fixes
|
||||||
* fix(render): disable rendering sub list when loadSidebar is false
|
|
||||||
|
|
||||||
# 3.0.3 / 2017-02-19
|
* style rerender due to setting themeColor ([17ff3d1](https://github.com/QingWei-Li/docsify/commit/17ff3d1))
|
||||||
|
|
||||||
* fixed look of links in blockquote
|
|
||||||
* fix(scroll) highlight bug
|
|
||||||
|
|
||||||
# 3.0.2 / 2017-02-19
|
|
||||||
|
|
||||||
* fix(search): add lazy input
|
<a name="4.2.1"></a>
|
||||||
* fix(compiler): link
|
## [4.2.1](https://github.com/QingWei-Li/docsify/compare/v4.2.0...v4.2.1) (2017-07-19)
|
||||||
|
|
||||||
# 3.0.1 / 2017-02-19
|
- give the navbar some line-height (#216)
|
||||||
|
- Remove unnecessary moduleName option from rollup config for plugins (#209)
|
||||||
|
|
||||||
* fix(route): empty alias
|
<a name="4.2.0"></a>
|
||||||
|
# [4.2.0](https://github.com/QingWei-Li/docsify/compare/v4.1.14...v4.2.0) (2017-07-10)
|
||||||
|
|
||||||
# 3.0.0 / 2017-02-19
|
|
||||||
|
|
||||||
#### Breaking change
|
### Bug Fixes
|
||||||
|
|
||||||
* Not support IE9
|
* not found page ([9af8559](https://github.com/QingWei-Li/docsify/commit/9af8559))
|
||||||
* The route becomes: `/#/page?id=slug`. The previous route will be redirected
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* alias option supports regexp, resolve [#183](https://github.com/QingWei-Li/docsify/issues/183) ([c4aa22c](https://github.com/QingWei-Li/docsify/commit/c4aa22c))
|
||||||
|
* ignore to compiled link, fixed [#203](https://github.com/QingWei-Li/docsify/issues/203) ([#204](https://github.com/QingWei-Li/docsify/issues/204)) ([2e00f4c](https://github.com/QingWei-Li/docsify/commit/2e00f4c))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.14"></a>
|
||||||
|
## [4.1.14](https://github.com/QingWei-Li/docsify/compare/v4.1.13...v4.1.14) (2017-06-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* get file path, fixed jrappen/sublime-distractionless/commit/81bfadd391428823191cc03eca956a2312e04d13#commitcomment-22427070 ([e8117e5](https://github.com/QingWei-Li/docsify/commit/e8117e5)), closes [jrappen/sublime-distractionless/commit/81bfadd391428823191cc03eca956a2312e04d13#commitcomment-22427070](https://github.com/jrappen/sublime-distractionless/commit/81bfadd391428823191cc03eca956a2312e04d13/issues/commitcomment-22427070)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add context attribute, fixed [#191](https://github.com/QingWei-Li/docsify/issues/191) ([ce0e9ac](https://github.com/QingWei-Li/docsify/commit/ce0e9ac))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.13"></a>
|
||||||
|
## [4.1.13](https://github.com/QingWei-Li/docsify/compare/v4.1.12...v4.1.13) (2017-06-11)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.12"></a>
|
||||||
|
## [4.1.12](https://github.com/QingWei-Li/docsify/compare/v4.1.11...v4.1.12) (2017-06-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **render:** ubtitle in side bar shows undefined, fixed [#182](https://github.com/QingWei-Li/docsify/issues/182) ([d087d57](https://github.com/QingWei-Li/docsify/commit/d087d57))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.11"></a>
|
||||||
|
## [4.1.11](https://github.com/QingWei-Li/docsify/compare/v4.1.10...v4.1.11) (2017-06-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **compiler:** force reset toc when rendering sidebar fixed [#181](https://github.com/QingWei-Li/docsify/issues/181) ([ccf4c7c](https://github.com/QingWei-Li/docsify/commit/ccf4c7c))
|
||||||
|
* **render:** autoHeader does not work ([1304d2e](https://github.com/QingWei-Li/docsify/commit/1304d2e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.10"></a>
|
||||||
|
## [4.1.10](https://github.com/QingWei-Li/docsify/compare/v4.1.9...v4.1.10) (2017-06-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **hash:** hash routing crashes when url has querystring ([6d48ce1](https://github.com/QingWei-Li/docsify/commit/6d48ce1))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.9"></a>
|
||||||
|
## [4.1.9](https://github.com/QingWei-Li/docsify/compare/v4.1.8...v4.1.9) (2017-05-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* can't render toc on first load ([d9b487e](https://github.com/QingWei-Li/docsify/commit/d9b487e))
|
||||||
|
* **lifecycle:** continue to handle data ([955d3d5](https://github.com/QingWei-Li/docsify/commit/955d3d5))
|
||||||
|
* **render:** broken name link, fixed [#167](https://github.com/QingWei-Li/docsify/issues/167) ([91b66a5](https://github.com/QingWei-Li/docsify/commit/91b66a5))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.8"></a>
|
||||||
|
## [4.1.8](https://github.com/QingWei-Li/docsify/compare/v4.1.7...v4.1.8) (2017-05-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* auto replace version ([22b50f0](https://github.com/QingWei-Li/docsify/commit/22b50f0))
|
||||||
|
* update edit button demo ([ec887c1](https://github.com/QingWei-Li/docsify/commit/ec887c1))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add edit button demo ([a64cee1](https://github.com/QingWei-Li/docsify/commit/a64cee1))
|
||||||
|
* add edit button demo, close [#162](https://github.com/QingWei-Li/docsify/issues/162) ([036fdac](https://github.com/QingWei-Li/docsify/commit/036fdac))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.7"></a>
|
||||||
|
## [4.1.7](https://github.com/QingWei-Li/docsify/compare/v4.1.6...v4.1.7) (2017-05-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **ssr:** clean files ([0014895](https://github.com/QingWei-Li/docsify/commit/0014895))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.6"></a>
|
||||||
|
## [4.1.6](https://github.com/QingWei-Li/docsify/compare/v4.1.5...v4.1.6) (2017-05-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **ssr:** add debug ([6b9e092](https://github.com/QingWei-Li/docsify/commit/6b9e092))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.5"></a>
|
||||||
|
## [4.1.5](https://github.com/QingWei-Li/docsify/compare/v4.1.4...v4.1.5) (2017-05-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **ssr:** missing package ([6db8c9e](https://github.com/QingWei-Li/docsify/commit/6db8c9e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.4"></a>
|
||||||
|
## [4.1.4](https://github.com/QingWei-Li/docsify/compare/v4.1.3...v4.1.4) (2017-05-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **ssr:** file path ([79a83bc](https://github.com/QingWei-Li/docsify/commit/79a83bc))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.3"></a>
|
||||||
|
## [4.1.3](https://github.com/QingWei-Li/docsify/compare/v4.1.2...v4.1.3) (2017-05-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* update babel config ([9825db4](https://github.com/QingWei-Li/docsify/commit/9825db4))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.2"></a>
|
||||||
|
## [4.1.2](https://github.com/QingWei-Li/docsify/compare/v4.1.1...v4.1.2) (2017-05-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* update babel config ([80dba19](https://github.com/QingWei-Li/docsify/commit/80dba19))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.1"></a>
|
||||||
|
## [4.1.1](https://github.com/QingWei-Li/docsify/compare/v4.1.0...v4.1.1) (2017-05-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* build for ssr package ([4cb20a5](https://github.com/QingWei-Li/docsify/commit/4cb20a5))
|
||||||
|
* remove history mode ([0e74e6c](https://github.com/QingWei-Li/docsify/commit/0e74e6c))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.1.0"></a>
|
||||||
|
# [4.1.0](https://github.com/QingWei-Li/docsify/compare/v4.0.2...v4.1.0) (2017-05-30)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.0.2"></a>
|
||||||
|
## [4.0.2](https://github.com/QingWei-Li/docsify/compare/v4.0.1...v4.0.2) (2017-05-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* basePath for history mode ([fc1cd3f](https://github.com/QingWei-Li/docsify/commit/fc1cd3f))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.0.1"></a>
|
||||||
|
## [4.0.1](https://github.com/QingWei-Li/docsify/compare/v4.0.0...v4.0.1) (2017-05-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **ssr:** remove context ([4626157](https://github.com/QingWei-Li/docsify/commit/4626157))
|
||||||
|
* lint ([b764b6e](https://github.com/QingWei-Li/docsify/commit/b764b6e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="4.0.0"></a>
|
||||||
|
# [4.0.0](https://github.com/QingWei-Li/docsify/compare/v3.7.3...v4.0.0) (2017-05-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **render:** init event in ssr ([eba1c98](https://github.com/QingWei-Li/docsify/commit/eba1c98))
|
||||||
|
* lint ([1f4514d](https://github.com/QingWei-Li/docsify/commit/1f4514d))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* finish ssr ([3444884](https://github.com/QingWei-Li/docsify/commit/3444884))
|
||||||
|
* init ocsify-server-renderer ([6dea685](https://github.com/QingWei-Li/docsify/commit/6dea685))
|
||||||
|
* support history mode ([f095eb8](https://github.com/QingWei-Li/docsify/commit/f095eb8))
|
||||||
|
|
||||||
#### Features
|
|
||||||
|
|
||||||
* Faster rendering
|
|
||||||
* Clearer source code
|
|
||||||
* More powerful API
|
|
||||||
* Auto header for each page [#78](https://github.com/QingWei-Li/docsify/issues/78)
|
|
||||||
* Localization for search plugin [#80](https://github.com/QingWei-Li/docsify/issues/80)
|
|
||||||
* Execute the script in markdown (see `executeScript`)
|
|
||||||
|
|||||||
+568
-344
File diff suppressed because it is too large
Load Diff
@@ -11,22 +11,26 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<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://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://www.npmjs.com/package/docsify"><img alt="npm" src="https://img.shields.io/npm/v/docsify.svg?style=flat-square"></a>
|
||||||
|
<a href="https://cdnjs.com/libraries/docsify"><img alt="cdnjs" src="https://img.shields.io/cdnjs/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://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>
|
</p>
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
- [Documentation](https://docsify.js.org)
|
- [Documentation](https://docsify.js.org)
|
||||||
- [CLI](https://github.com/QingWei-Li/docsify-cli)
|
- [CLI](https://github.com/QingWei-Li/docsify-cli)
|
||||||
|
- CDN: [UNPKG](https://unpkg.com/docsify/) | [jsDelivr](https://cdn.jsdelivr.net/npm/docsify/)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- No statically built html files
|
- No statically built html files
|
||||||
- Simple and lightweight (~16kB gzipped)
|
- Simple and lightweight (~18kB gzipped)
|
||||||
- Smart full-text search plugin
|
- Smart full-text search plugin
|
||||||
- Multiple themes
|
- Multiple themes
|
||||||
- Useful plugin API
|
- Useful plugin API
|
||||||
- Compatible with IE10+
|
- Compatible with IE10+
|
||||||
|
- Support SSR ([example](https://github.com/QingWei-Li/docsify-ssr-demo))
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
@@ -39,12 +43,12 @@ Create an `index.html`.
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -54,7 +58,7 @@ Modern browsers and Internet Explorer 10+.
|
|||||||
|
|
||||||
## Showcase
|
## 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 |
|
| Project | Description |
|
||||||
|---|---|
|
|---|---|
|
||||||
@@ -64,6 +68,14 @@ These open-source projects are using docsify to generate their sites. Pull reque
|
|||||||
| [Vudash](http://vudash.github.io/vudash/) | Powerful, Flexible, Open Source dashboards for anything |
|
| [Vudash](http://vudash.github.io/vudash/) | Powerful, Flexible, Open Source dashboards for anything |
|
||||||
| [Trilogy](http://trilogy.js.org) | No-hassle SQLite with a Promise-based, document store style API. |
|
| [Trilogy](http://trilogy.js.org) | No-hassle SQLite with a Promise-based, document store style API. |
|
||||||
| [Mybatis-Plus](http://mp.baomidou.com/) | An enhanced toolkit of Mybatis to simplify development |
|
| [Mybatis-Plus](http://mp.baomidou.com/) | An enhanced toolkit of Mybatis to simplify development |
|
||||||
|
| [JS MythBusters](https://mythbusters.js.org) | An optimization handbook from a high level point of view. |
|
||||||
|
| [hire-me](https://fvcproductions.github.io/hire-me) | A path to getting an awesome tech gig. |
|
||||||
|
| [vue-amap](https://elemefe.github.io/vue-amap/) | A Map Component Library Base on Vue 2.x and Gaode Map. |
|
||||||
|
| [samlify](https://samlify.js.org) | Node.js SAML2 library |
|
||||||
|
| [palettify](https://dobromir-hristov.github.io/palettify/) | A color palette effects assistant |
|
||||||
|
| [commitlint](https://marionebl.github.io/commitlint/) | Lint commit messages |
|
||||||
|
| [vue-data-tables](https://github.com/njleonzhang/vue-data-tables/) | A simple and customizable data table,based on vue2 and element-ui. |
|
||||||
|
| [Noty](http://ned.im/noty/) | A Dependency-free notification library |
|
||||||
|
|
||||||
## Similar projects
|
## Similar projects
|
||||||
|
|
||||||
@@ -84,10 +96,12 @@ These open-source projects are using docsify to generate their sites. Pull reque
|
|||||||
## Development
|
## Development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm i && npm run dev
|
npm run bootstrap && npm run dev
|
||||||
open http://localhost:3000
|
open http://localhost:3000
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
MIT
|
||||||
|
|
||||||
|
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FQingWei-Li%2Fdocsify?ref=badge_large)
|
||||||
|
|||||||
@@ -1,12 +1,51 @@
|
|||||||
var serveStatic = require('serve-static')
|
var serveStatic = require('serve-static')
|
||||||
var http = require('http')
|
var http = require('http')
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
|
var Renderer = require('./packages/docsify-server-renderer/build.js')
|
||||||
|
|
||||||
|
var renderer = new Renderer({
|
||||||
|
template: `
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>docsify</title>
|
||||||
|
<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="/themes/vue.css" title="vue">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!--inject-app-->
|
||||||
|
<!--inject-config-->
|
||||||
|
<script src="/lib/docsify.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>`,
|
||||||
|
config: {
|
||||||
|
name: 'docsify',
|
||||||
|
repo: 'qingwei-li/docsify',
|
||||||
|
basePath: 'https://docsify.js.org/',
|
||||||
|
loadNavbar: true,
|
||||||
|
loadSidebar: true,
|
||||||
|
subMaxLevel: 3,
|
||||||
|
auto2top: true,
|
||||||
|
alias: {
|
||||||
|
'/de-de/changelog': '/changelog',
|
||||||
|
'/zh-cn/changelog': '/changelog',
|
||||||
|
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
path: './'
|
||||||
|
})
|
||||||
|
|
||||||
http.createServer(function (req, res) {
|
http.createServer(function (req, res) {
|
||||||
serveStatic('.')(req, res, function () {
|
serveStatic('.')(req, res, function () {
|
||||||
|
// TEST SSR
|
||||||
|
// renderer.renderToString(req.url)
|
||||||
|
// .then(html => res.end(html))
|
||||||
|
|
||||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||||
res.end(fs.readFileSync('dev.html'))
|
res.end(fs.readFileSync('dev.html'))
|
||||||
})
|
})
|
||||||
}).listen(3000, '0.0.0.0')
|
}).listen(3000, '0.0.0.0')
|
||||||
|
|
||||||
console.log(`\nListening at http://0.0.0.0:3000\n`)
|
console.log(`\nListening at http://0.0.0.0:3000\n`)
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
var rollup = require('rollup')
|
||||||
|
var buble = require('rollup-plugin-buble')
|
||||||
|
var async = require('rollup-plugin-async')
|
||||||
|
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
|
||||||
|
}
|
||||||
|
})
|
||||||
|
],
|
||||||
|
onwarn: function() {}
|
||||||
|
})
|
||||||
|
.then(function (bundle) {
|
||||||
|
var dest = 'packages/docsify-server-renderer/build.js'
|
||||||
|
|
||||||
|
console.log(dest)
|
||||||
|
bundle.write({
|
||||||
|
format: 'cjs',
|
||||||
|
dest: dest
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
+13
-11
@@ -4,7 +4,9 @@ var commonjs = require('rollup-plugin-commonjs')
|
|||||||
var nodeResolve = require('rollup-plugin-node-resolve')
|
var nodeResolve = require('rollup-plugin-node-resolve')
|
||||||
var string = require('rollup-plugin-string')
|
var string = require('rollup-plugin-string')
|
||||||
var uglify = require('rollup-plugin-uglify')
|
var uglify = require('rollup-plugin-uglify')
|
||||||
|
var replace = require('rollup-plugin-replace')
|
||||||
var isProd = process.argv[process.argv.length - 1] !== '--dev'
|
var isProd = process.argv[process.argv.length - 1] !== '--dev'
|
||||||
|
var version = process.env.VERSION || require('../package.json').version
|
||||||
|
|
||||||
var build = function (opts) {
|
var build = function (opts) {
|
||||||
rollup
|
rollup
|
||||||
@@ -14,7 +16,10 @@ var build = function (opts) {
|
|||||||
string({ include: '**/*.css' }),
|
string({ include: '**/*.css' }),
|
||||||
buble(),
|
buble(),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
nodeResolve()
|
nodeResolve(),
|
||||||
|
replace({
|
||||||
|
__VERSION__: version
|
||||||
|
})
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
.then(function (bundle) {
|
.then(function (bundle) {
|
||||||
@@ -23,7 +28,6 @@ var build = function (opts) {
|
|||||||
console.log(dest)
|
console.log(dest)
|
||||||
bundle.write({
|
bundle.write({
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
moduleName: opts.moduleName || 'D',
|
|
||||||
dest: dest
|
dest: dest
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -38,19 +42,18 @@ build({
|
|||||||
})
|
})
|
||||||
|
|
||||||
var plugins = [
|
var plugins = [
|
||||||
{ name: 'search', entry: 'search/index.js', moduleName: 'Search' },
|
{ name: 'search', entry: 'search/index.js' },
|
||||||
{ name: 'ga', entry: 'ga.js', moduleName: 'GA' },
|
{ name: 'ga', entry: 'ga.js' },
|
||||||
{ name: 'emoji', entry: 'emoji.js', moduleName: 'Emoji' },
|
{ name: 'emoji', entry: 'emoji.js' },
|
||||||
{ name: 'external-script', entry: 'external-script.js', moduleName: 'ExternalScript' },
|
{ name: 'external-script', entry: 'external-script.js' },
|
||||||
{ name: 'front-matter', entry: 'front-matter/index.js', moduleName: 'FrontMatter' },
|
{ name: 'front-matter', entry: 'front-matter/index.js' },
|
||||||
{ name: 'zoom-image', entry: 'zoom-image.js', moduleName: 'ZoomImage' }
|
{ name: 'zoom-image', entry: 'zoom-image.js' }
|
||||||
]
|
]
|
||||||
|
|
||||||
plugins.forEach(item => {
|
plugins.forEach(item => {
|
||||||
build({
|
build({
|
||||||
entry: 'plugins/' + item.entry,
|
entry: 'plugins/' + item.entry,
|
||||||
output: 'plugins/' + item.name + '.js',
|
output: 'plugins/' + item.name + '.js'
|
||||||
moduleName: 'D.' + item.moduleName
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -64,7 +67,6 @@ if (isProd) {
|
|||||||
build({
|
build({
|
||||||
entry: 'plugins/' + item.entry,
|
entry: 'plugins/' + item.entry,
|
||||||
output: 'plugins/' + item.name + '.min.js',
|
output: 'plugins/' + item.name + '.min.js',
|
||||||
moduleName: 'D.' + item.moduleName,
|
|
||||||
plugins: [uglify()]
|
plugins: [uglify()]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ -z $1 ]]; then
|
||||||
|
echo "Enter new version: "
|
||||||
|
read VERSION
|
||||||
|
else
|
||||||
|
VERSION=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -p "Releasing $VERSION $RELEASE_TAG - are you sure? (y/n) " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo "Releasing $VERSION ..."
|
||||||
|
|
||||||
|
npm run test
|
||||||
|
|
||||||
|
# build
|
||||||
|
VERSION=$VERSION npm run build
|
||||||
|
|
||||||
|
# update packages
|
||||||
|
cd packages/docsify-server-renderer
|
||||||
|
npm version $VERSION
|
||||||
|
if [[ -z $RELEASE_TAG ]]; then
|
||||||
|
npm publish
|
||||||
|
else
|
||||||
|
npm publish --tag $RELEASE_TAG
|
||||||
|
fi
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# commit
|
||||||
|
git add -A
|
||||||
|
git commit -m "[build] $VERSION $RELEASE_TAG"
|
||||||
|
npm --no-git-tag-version version $VERSION --message "[release] $VERSION $RELEASE_TAG"
|
||||||
|
|
||||||
|
# changelog
|
||||||
|
node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s
|
||||||
|
|
||||||
|
git add .
|
||||||
|
git commit -m "chore: add changelog $VERSION"
|
||||||
|
|
||||||
|
# publish
|
||||||
|
git tag v$VERSION
|
||||||
|
git push origin refs/tags/v$VERSION
|
||||||
|
git push
|
||||||
|
if [[ -z $RELEASE_TAG ]]; then
|
||||||
|
npm publish
|
||||||
|
else
|
||||||
|
npm publish --tag $RELEASE_TAG
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@@ -19,19 +19,34 @@
|
|||||||
<script>
|
<script>
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
alias: {
|
alias: {
|
||||||
'/de-de/changelog': '/changelog',
|
'.*?/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG',
|
||||||
'/zh-cn/changelog': '/changelog',
|
'/.*/_navbar.md': '/_navbar.md'
|
||||||
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
|
||||||
},
|
},
|
||||||
|
auto2top: true,
|
||||||
|
basePath: '/docs/',
|
||||||
|
executeScript: true,
|
||||||
loadNavbar: true,
|
loadNavbar: true,
|
||||||
executeScript: true
|
loadSidebar: true,
|
||||||
|
coverpage: true,
|
||||||
|
name: 'docsify',
|
||||||
|
subMaxLevel: 0,
|
||||||
|
mergeNavbar: true,
|
||||||
|
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||||
|
plugins: [
|
||||||
|
function(hook, vm) {
|
||||||
|
hook.beforeEach(function (html) {
|
||||||
|
var url = 'https://github.com/QingWei-Li/docsify/blob/master/' + vm.route.file
|
||||||
|
var editHtml = '[:memo: Edit Document](' + url + ')\n'
|
||||||
|
|
||||||
|
return editHtml
|
||||||
|
+ html
|
||||||
|
+ '\n----\n'
|
||||||
|
+ 'Last modified {docsify-updated} '
|
||||||
|
+ editHtml
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script
|
<script src="/lib/docsify.js"></script>
|
||||||
src="/lib/docsify.js"
|
|
||||||
data-name="docsify"
|
|
||||||
data-base-path="/docs/"
|
|
||||||
data-load-sidebar
|
|
||||||
data-sub-max-level="2"
|
|
||||||
data-auto2top></script>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+4
-3
@@ -4,19 +4,20 @@
|
|||||||
|
|
||||||
## What is it
|
## What is it
|
||||||
|
|
||||||
docsify generates your documentation website on the fly. Unlike GitBook, it does not generate static html files. Instead, it smartly loads and parses your Markdown files and displays them as website. All you need to do is create an `index.html` to start and [deploy it on GitHub Pages](/deploy).
|
docsify generates your documentation website on the fly. Unlike GitBook, it does not generate static html files. Instead, it smartly loads and parses your Markdown files and displays them as website. All you need to do is create an `index.html` to start and [deploy it on GitHub Pages](deploy.md).
|
||||||
|
|
||||||
See the [Quick start](/quickstart) for more details.
|
See the [Quick start](quickstart.md) for more details.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* No statically built html files
|
* No statically built html files
|
||||||
* Simple and lightweight (~16kB gzipped)
|
* Simple and lightweight (~18kB gzipped)
|
||||||
* Smart full-text search plugin
|
* Smart full-text search plugin
|
||||||
* Multiple themes
|
* Multiple themes
|
||||||
* Useful plugin API
|
* Useful plugin API
|
||||||
* Emoji support
|
* Emoji support
|
||||||
* Compatible with IE10+
|
* Compatible with IE10+
|
||||||
|
- Support SSR ([example](https://github.com/QingWei-Li/docsify-ssr-demo))
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||

|

|
||||||
|
|
||||||
# docsify <small>3.4</small>
|
# docsify <small>4.2.7</small>
|
||||||
|
|
||||||
> A magical documentation site generator.
|
> A magical documentation site generator.
|
||||||
|
|
||||||
- Simple and lightweight (~16kB gzipped)
|
- Simple and lightweight (~18kB gzipped)
|
||||||
- No statically built html files
|
- No statically built html files
|
||||||
- Multiple themes
|
- Multiple themes
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
- :uk:
|
- Translations
|
||||||
- [:cn: 中文](/zh-cn/)
|
- [:cn: 中文](/zh-cn/)
|
||||||
- [:de: German](/de-de/)
|
- [:de: Deutsch](/de-de/)
|
||||||
- [:uk: English](/)
|
- [:uk: English](/)
|
||||||
|
|||||||
+17
-16
@@ -1,22 +1,23 @@
|
|||||||
- Getting started
|
- Getting started
|
||||||
- [Quick start](/quickstart)
|
- [Quick start](quickstart.md)
|
||||||
- [Writing more pages](/more-pages)
|
- [Writing more pages](more-pages.md)
|
||||||
- [Custom navbar](/custom-navbar)
|
- [Custom navbar](custom-navbar.md)
|
||||||
- [Cover page](/cover)
|
- [Cover page](cover.md)
|
||||||
|
|
||||||
- Customization
|
- Customization
|
||||||
- [Configuration](/configuration)
|
- [Configuration](configuration.md)
|
||||||
- [Themes](/themes)
|
- [Themes](themes.md)
|
||||||
- [List of Plugins](/plugins)
|
- [List of Plugins](plugins.md)
|
||||||
- [Write a Plugin](/write-a-plugin)
|
- [Write a Plugin](write-a-plugin.md)
|
||||||
- [Markdown configuration](/markdown)
|
- [Markdown configuration](markdown.md)
|
||||||
- [Language highlighting](/language-highlight)
|
- [Language highlighting](language-highlight.md)
|
||||||
|
|
||||||
- Guide
|
- Guide
|
||||||
- [Deploy](/deploy)
|
- [Deploy](deploy.md)
|
||||||
- [Helpers](/helpers)
|
- [Helpers](helpers.md)
|
||||||
- [Vue compatibility](/vue)
|
- [Vue compatibility](vue.md)
|
||||||
- [CDN](/cdn)
|
- [CDN](cdn.md)
|
||||||
- [Offline Mode(PWA)](/pwa)
|
- [Offline Mode(PWA)](pwa.md)
|
||||||
|
- [Server-client renderer(SSR)](ssr.md)
|
||||||
|
|
||||||
- [Changelog](/changelog)
|
- [Changelog](changelog.md)
|
||||||
|
|||||||
+4
-1
@@ -44,4 +44,7 @@ Alternatively, use [compressed files](#compressed-files).
|
|||||||
|
|
||||||
## Other CDN
|
## Other CDN
|
||||||
|
|
||||||
[jsDelivr](http://www.jsdelivr.com/projects/docsify) is available.
|
- http://www.bootcdn.cn/docsify
|
||||||
|
- https://cdn.jsdelivr.net/npm/docsify/
|
||||||
|
- https://cdnjs.com/libraries/docsify
|
||||||
|
|
||||||
|
|||||||
+79
-4
@@ -166,7 +166,7 @@ window.$docsify = {
|
|||||||
- Type: `Boolean|String`
|
- Type: `Boolean|String`
|
||||||
- Default: `false`
|
- Default: `false`
|
||||||
|
|
||||||
Activate the [cover feature](/cover). If true, it will load from `_coverpage.md`.
|
Activate the [cover feature](cover.md). If true, it will load from `_coverpage.md`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -212,7 +212,7 @@ window.$docsify = {
|
|||||||
|
|
||||||
- Type: `Function`
|
- Type: `Function`
|
||||||
|
|
||||||
See [Markdown configuration](/markdown).
|
See [Markdown configuration](markdown.md).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -250,11 +250,12 @@ window.$docsify = {
|
|||||||
|
|
||||||
- Type: `Object`
|
- Type: `Object`
|
||||||
|
|
||||||
Set the route alias. You can freely manage routing rules.
|
Set the route alias. You can freely manage routing rules. Supports RegExp.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
alias: {
|
alias: {
|
||||||
|
'/foo/(+*)': '/bar/$1', // supports regexp
|
||||||
'/zh-cn/changelog': '/changelog',
|
'/zh-cn/changelog': '/changelog',
|
||||||
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||||
}
|
}
|
||||||
@@ -294,10 +295,12 @@ window.$docsify = {
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that if you are running an external script, e.g. an embedded jsfiddle demo, make sure to include the [external-script](plugins?id=external-script) plugin.
|
Note that if you are running an external script, e.g. an embedded jsfiddle demo, make sure to include the [external-script](plugins.md?id=external-script) plugin.
|
||||||
|
|
||||||
## no-emoji
|
## no-emoji
|
||||||
|
|
||||||
|
- type: `Boolean`
|
||||||
|
|
||||||
Disabled emoji parse.
|
Disabled emoji parse.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -305,3 +308,75 @@ window.$docsify = {
|
|||||||
noEmoji: true
|
noEmoji: true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## merge-navbar
|
||||||
|
|
||||||
|
- type: `Boolean`
|
||||||
|
|
||||||
|
Navbar will be merged with the sidebar on smaller screens.
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
mergeNavbar: true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## format-updated
|
||||||
|
|
||||||
|
- type: `String|Function`
|
||||||
|
|
||||||
|
We can display the file update date through **{docsify-updated<span>}</span>** variable. And format it by `formatUpdated`.
|
||||||
|
See https://github.com/lukeed/tinydate#patterns
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||||
|
|
||||||
|
formatUpdated: function (time) {
|
||||||
|
// ...
|
||||||
|
|
||||||
|
return time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## external-link-target
|
||||||
|
|
||||||
|
- type: `String`
|
||||||
|
- default: `_self`
|
||||||
|
|
||||||
|
Target to open external links. Default `'_blank'` (new window/tab)
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
externalLinkTarget: '_self' // default: '_blank'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## router-mode
|
||||||
|
|
||||||
|
- type: `String`
|
||||||
|
- default: `history`
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
routerMode: 'history' // default: 'hash'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## noCompileLinks
|
||||||
|
|
||||||
|
- type: `Array`
|
||||||
|
|
||||||
|
|
||||||
|
Sometimes we do not want docsify to handle our links. See [#203](https://github.com/QingWei-Li/docsify/issues/203)
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
noCompileLinks: [
|
||||||
|
'/foo',
|
||||||
|
'/bar/.*'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
# Cover
|
# Cover
|
||||||
|
|
||||||
Activate the cover feature by setting `coverpage` to **true**, compare [coverpage configuration](configuration#coverpage).
|
Activate the cover feature by setting `coverpage` to **true**, compare [coverpage configuration](configuration.md#coverpage).
|
||||||
|
|
||||||
## Basic usage
|
## Basic usage
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ Set `coverpage` to **true**, and create a `_coverpage.md`:
|
|||||||
|
|
||||||
> A magical documentation site generator.
|
> A magical documentation site generator.
|
||||||
|
|
||||||
- Simple and lightweight (~16kB gzipped)
|
- Simple and lightweight (~18kB gzipped)
|
||||||
- No statically built html files
|
- No statically built html files
|
||||||
- Multiple themes
|
- Multiple themes
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -20,7 +20,7 @@ If you need custom navigation, you can create a HTML-based navigation bar.
|
|||||||
|
|
||||||
## Markdown
|
## Markdown
|
||||||
|
|
||||||
Alternatively, you can create a custom markdown-based navigation file by setting `loadNavbar` to **true** and creating `_navbar.md`, compare [load-navbar configuration](configuration#load-navbar).
|
Alternatively, you can create a custom markdown-based navigation file by setting `loadNavbar` to **true** and creating `_navbar.md`, compare [load-navbar configuration](configuration.md#load-navbar).
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- index.html -->
|
<!-- index.html -->
|
||||||
@@ -52,17 +52,17 @@ You can create sub-lists by indenting items that are under a certain parent.
|
|||||||
<!-- _navbar.md -->
|
<!-- _navbar.md -->
|
||||||
|
|
||||||
- Getting started
|
- Getting started
|
||||||
- [Quick start](/quickstart)
|
- [Quick start](quickstart.md)
|
||||||
- [Writing more pages](/more-pages)
|
- [Writing more pages](more-pages.md)
|
||||||
- [Custom navbar](/custom-navbar)
|
- [Custom navbar](custom-navbar.md)
|
||||||
- [Cover page](/cover)
|
- [Cover page](cover.md)
|
||||||
|
|
||||||
- Configuration
|
- Configuration
|
||||||
- [Configuration](/configuration)
|
- [Configuration](configuration.md)
|
||||||
- [Themes](/themes)
|
- [Themes](themes.md)
|
||||||
- [Using plugins](/plugins)
|
- [Using plugins](plugins.md)
|
||||||
- [Markdown configuration](/markdown)
|
- [Markdown configuration](markdown.md)
|
||||||
- [Language highlight](/language-highlight)
|
- [Language highlight](language-highlight.md)
|
||||||
```
|
```
|
||||||
|
|
||||||
renders as
|
renders as
|
||||||
|
|||||||
@@ -4,19 +4,20 @@
|
|||||||
|
|
||||||
## Was ist das
|
## Was ist das
|
||||||
|
|
||||||
**docsify** generiert deine Dokumentationswebseite zeitgleich (mit der Darstellung). Im Gegensatz zu GitBook, werden keine statischen HTML Seiten generiert. Stattdessen, werden im Hintergrund Markdown Dateien geladen und umgewandelt, und als Webseite dargestellt. Alles, was du brauchst, ist eine Datei namens `index.html`, um sie über [GitHub Pages zu veröffentlichen](/de-de/deploy).
|
**docsify** generiert deine Dokumentationswebseite zeitgleich (mit der Darstellung). Im Gegensatz zu GitBook, werden keine statischen HTML Seiten generiert. Stattdessen, werden im Hintergrund Markdown Dateien geladen und umgewandelt, und als Webseite dargestellt. Alles, was du brauchst, ist eine Datei namens `index.html`, um sie über [GitHub Pages zu veröffentlichen](de-de/deploy.md).
|
||||||
|
|
||||||
Siehe [Schnellstart](/de-de/quickstart) für weitere Informationen.
|
Siehe [Schnellstart](de-de/quickstart.md) für weitere Informationen.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* keine generierten, statischen HTML Dateien
|
* keine generierten, statischen HTML Dateien
|
||||||
* einfach und klein (~16kB gzipped)
|
* einfach und klein (~18kB gzipped)
|
||||||
* smarte Erweiterung mit Volltextsuche
|
* smarte Erweiterung mit Volltextsuche
|
||||||
* mehrere Themes
|
* mehrere Themes
|
||||||
* praktische API für Erweiterungen
|
* praktische API für Erweiterungen
|
||||||
* Unterstützung für Emoji
|
* Unterstützung für Emoji
|
||||||
* Kompatibel mit IE10+
|
* Kompatibel mit IE10+
|
||||||
|
- Support SSR ([example](https://github.com/QingWei-Li/docsify-ssr-demo))
|
||||||
|
|
||||||
## Beispiele
|
## Beispiele
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
- :de:
|
|
||||||
- [:cn: 中文](/zh-cn/)
|
|
||||||
- [:de: German](/de-de/)
|
|
||||||
- [:uk: English](/)
|
|
||||||
+17
-16
@@ -1,22 +1,23 @@
|
|||||||
- Loslegen
|
- Loslegen
|
||||||
- [Schnellstart](/de-de/quickstart)
|
- [Schnellstart](de-de/quickstart.md)
|
||||||
- [Schreiben weiterer Seiten](/de-de/more-pages)
|
- [Schreiben weiterer Seiten](de-de/more-pages.md)
|
||||||
- [Navigationsleiste anpassen](/de-de/custom-navbar)
|
- [Navigationsleiste anpassen](de-de/custom-navbar.md)
|
||||||
- [Titelseite](/de-de/cover)
|
- [Titelseite](de-de/cover.md)
|
||||||
|
|
||||||
- Anpassen
|
- Anpassen
|
||||||
- [Einstellungen](/de-de/configuration)
|
- [Einstellungen](de-de/configuration.md)
|
||||||
- [Themen](/de-de/themes)
|
- [Themen](de-de/themes.md)
|
||||||
- [Liste der Erweiterungen](/de-de/plugins)
|
- [Liste der Erweiterungen](de-de/plugins.md)
|
||||||
- [Schreiben eigener Erweiterungen](/de-de/write-a-plugin)
|
- [Schreiben eigener Erweiterungen](de-de/write-a-plugin.md)
|
||||||
- [Markdown-Einstellungen](/de-de/markdown)
|
- [Markdown-Einstellungen](de-de/markdown.md)
|
||||||
- [Hervorheben von Sprachen](/de-de/language-highlight)
|
- [Hervorheben von Sprachen](de-de/language-highlight.md)
|
||||||
|
|
||||||
- Guide
|
- Guide
|
||||||
- [Inbetriebnahme](/de-de/deploy)
|
- [Inbetriebnahme](de-de/deploy.md)
|
||||||
- [Helfer](/de-de/helpers)
|
- [Helfer](de-de/helpers.md)
|
||||||
- [Vue Kompatibilität](/de-de/vue)
|
- [Vue Kompatibilität](de-de/vue.md)
|
||||||
- [CDN](/de-de/cdn)
|
- [CDN](de-de/cdn.md)
|
||||||
- [Offline Modus (PWA)](/de-de/pwa)
|
- [Offline Modus (PWA)](de-de/pwa.md)
|
||||||
|
- [Server-client renderer (SSR)](de-de/ssr.md)
|
||||||
|
|
||||||
- [Changelog](/de-de/changelog)
|
- [Changelog](de-de/changelog.md)
|
||||||
|
|||||||
+3
-1
@@ -44,4 +44,6 @@ Alternativ kannst du auch die [komprimierten Dateien](#komprimierte-dateien) ver
|
|||||||
|
|
||||||
## Andere CDN
|
## Andere CDN
|
||||||
|
|
||||||
[jsDelivr](http://www.jsdelivr.com/projects/docsify) ist auch verfügbar.
|
- http://www.bootcdn.cn/docsify
|
||||||
|
- https://cdn.jsdelivr.net/npm/docsify/
|
||||||
|
- https://cdnjs.com/libraries/docsify
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ window.$docsify = {
|
|||||||
- Typ: `Boolean|String`
|
- Typ: `Boolean|String`
|
||||||
- Standard: `false`
|
- Standard: `false`
|
||||||
|
|
||||||
Aktiviere das [Titelseitenfeature](/de-de/cover). Falls `true`, wird sie von `_coverpage.md` geladen.
|
Aktiviere das [Titelseitenfeature](de-de/cover.md). Falls `true`, wird sie von `_coverpage.md` geladen.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -212,7 +212,7 @@ window.$docsify = {
|
|||||||
|
|
||||||
- Typ: `Function`
|
- Typ: `Function`
|
||||||
|
|
||||||
Siehe [Markdown Konfiguration](/de-de/markdown).
|
Siehe [Markdown Konfiguration](de-de/markdown.md).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -250,11 +250,12 @@ window.$docsify = {
|
|||||||
|
|
||||||
- Typ: `Object`
|
- Typ: `Object`
|
||||||
|
|
||||||
Verwende alternative Routen. Du kannst sie ungehindert anpassen.
|
Verwende alternative Routen. Du kannst sie ungehindert anpassen. Supports RegExp.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
alias: {
|
alias: {
|
||||||
|
'/foo/(+*)': '/bar/$1', // supports regexp
|
||||||
'/zh-cn/changelog': '/changelog',
|
'/zh-cn/changelog': '/changelog',
|
||||||
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||||
}
|
}
|
||||||
@@ -278,7 +279,7 @@ window.$docsify = {
|
|||||||
|
|
||||||
- Typ: `Boolean`
|
- Typ: `Boolean`
|
||||||
|
|
||||||
Führe das Skript auf der Seite aus. Analysiere nur das erste script tag ([demo](/de-de/themes)). Sollte Vue verwendet sein, wird es in der Standardeinstellung ausgeführt.
|
Führe das Skript auf der Seite aus. Analysiere nur das erste script tag ([demo](de-de/themes.md)). Sollte Vue verwendet sein, wird es in der Standardeinstellung ausgeführt.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -294,7 +295,7 @@ window.$docsify = {
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
?> Nehme zur Kenntnis, dass, solltest du ein externes Skript ausführen, z.B. ein eingebettete jsfiddle demo, du sicher gehen solltest, das [external-script](plugins?id=external-script) plugin zu verwenden.
|
?> Nehme zur Kenntnis, dass, solltest du ein externes Skript ausführen, z.B. ein eingebettete jsfiddle demo, du sicher gehen solltest, das [external-script](de-de/plugins.md?id=external-script) plugin zu verwenden.
|
||||||
|
|
||||||
## no-emoji
|
## no-emoji
|
||||||
|
|
||||||
@@ -305,3 +306,56 @@ window.$docsify = {
|
|||||||
noEmoji: true
|
noEmoji: true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## merge-navbar
|
||||||
|
|
||||||
|
Navbar will be merged with the sidebar on smaller screens.
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
mergeNavbar: true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## format-updated
|
||||||
|
We can display the file update date through **{docsify-updated<span>}</span>** variable. And format it by `formatUpdated`.
|
||||||
|
See https://github.com/lukeed/tinydate#patterns
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||||
|
|
||||||
|
formatUpdated: function (time) {
|
||||||
|
// ...
|
||||||
|
|
||||||
|
return time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## external-link-target
|
||||||
|
|
||||||
|
Currently it defaults to _blank, would be nice if configurable:
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
externalLinkTarget: '_self' // default: '_blank'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## noCompileLinks
|
||||||
|
|
||||||
|
- type: `Array`
|
||||||
|
|
||||||
|
|
||||||
|
Sometimes we do not want docsify to handle our links. See [#203](https://github.com/QingWei-Li/docsify/issues/203)
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
noCompileLinks: [
|
||||||
|
'/foo',
|
||||||
|
'/bar/.*'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
# Titelseite
|
# Titelseite
|
||||||
|
|
||||||
Aktiviere die Unterstützung für Titelseiten, indem du `coverpage` auf **true** einstellst, vergleiche [coverpage Einstellungen](/de-de/configuration#coverpage).
|
Aktiviere die Unterstützung für Titelseiten, indem du `coverpage` auf **true** einstellst, vergleiche [coverpage Einstellungen](configuration.md#coverpage).
|
||||||
|
|
||||||
## Einfache Verwendung
|
## Einfache Verwendung
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ Setze `coverpage` auf **true**, und erstelle `_coverpage.md`:
|
|||||||
|
|
||||||
> Ein magischer Generator für Dokumentationsseiten.
|
> Ein magischer Generator für Dokumentationsseiten.
|
||||||
|
|
||||||
- Einfach und wenig Speicherbedarf (~16kB gzipped)
|
- Einfach und wenig Speicherbedarf (~18kB gzipped)
|
||||||
- Keine statischen HTML Dateien
|
- Keine statischen HTML Dateien
|
||||||
- Mehrere Themes
|
- Mehrere Themes
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -20,7 +20,7 @@ Solltest du eine Navigationsleiste benötigen, so kannst du eine HTML-basierte e
|
|||||||
|
|
||||||
## Markdown
|
## Markdown
|
||||||
|
|
||||||
Oder du kannst deine Navigationsleiste mit einer Datei basierend auf Markdown erstellen, indem du `loadNavbar` auf **true** setzt und eine Datei namens `_navbar.md` erstellst, vergleiche [load-navbar Einstellungen](/de-de/configuration#load-navbar).
|
Oder du kannst deine Navigationsleiste mit einer Datei basierend auf Markdown erstellen, indem du `loadNavbar` auf **true** setzt und eine Datei namens `_navbar.md` erstellst, vergleiche [load-navbar Einstellungen](configuration.md#load-navbar).
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- index.html -->
|
<!-- index.html -->
|
||||||
@@ -52,17 +52,17 @@ Du kannst untergeordnete Listen erstellen, indem du untergeordnete Punkte einem
|
|||||||
<!-- _navbar.md -->
|
<!-- _navbar.md -->
|
||||||
|
|
||||||
- Getting started
|
- Getting started
|
||||||
- [Quick start](/quickstart)
|
- [Quick start](de-de/quickstart.md)
|
||||||
- [Writing more pages](/more-pages)
|
- [Writing more pages](de-de/more-pages.md)
|
||||||
- [Custom navbar](/custom-navbar)
|
- [Custom navbar](de-de/custom-navbar.md)
|
||||||
- [Cover page](/cover)
|
- [Cover page](de-de/cover.md)
|
||||||
|
|
||||||
- Configuration
|
- Configuration
|
||||||
- [Configuration](/configuration)
|
- [Configuration](de-de/configuration.md)
|
||||||
- [Themes](/themes)
|
- [Themes](de-de/themes.md)
|
||||||
- [Using plugins](/plugins)
|
- [Using plugins](de-de/plugins.md)
|
||||||
- [Markdown configuration](/markdown)
|
- [Markdown configuration](de-de/markdown.md)
|
||||||
- [Language highlight](/language-highlight)
|
- [Language highlight](de-de/language-highlight.md)
|
||||||
```
|
```
|
||||||
|
|
||||||
wird also wie folgt aussehen
|
wird also wie folgt aussehen
|
||||||
@@ -71,7 +71,7 @@ wird also wie folgt aussehen
|
|||||||
|
|
||||||
## Angepasste Navigationsleisten in Verbindung mit dem emoji Erweiterung
|
## Angepasste Navigationsleisten in Verbindung mit dem emoji Erweiterung
|
||||||
|
|
||||||
Solltest du die [emoji Erweiterung](/de-de/plugins#emoji) verwenden:
|
Solltest du die [emoji Erweiterung](plugins.md#emoji) verwenden:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- index.html -->
|
<!-- index.html -->
|
||||||
|
|||||||
@@ -25,3 +25,27 @@ Generelle Tipps wie:
|
|||||||
wird wie folgt gerendert:
|
wird wie folgt gerendert:
|
||||||
|
|
||||||
?> *TODO* unit test
|
?> *TODO* unit test
|
||||||
|
|
||||||
|
## Ignore to compile link
|
||||||
|
|
||||||
|
Some time we will put some other relative path to the link, you have to need to tell docsify you don't need to compile this link. For example
|
||||||
|
|
||||||
|
```md
|
||||||
|
[link](/demo/)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
It will be compiled to `<a href="/#/demo/">link</a>` and will be loaded `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.
|
||||||
|
|
||||||
|
Now you can do that
|
||||||
|
|
||||||
|
```md
|
||||||
|
[link](/demo/ ":ignore")
|
||||||
|
```
|
||||||
|
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set title for link.
|
||||||
|
|
||||||
|
```md
|
||||||
|
[link](/demo/ ":ignore title")
|
||||||
|
|
||||||
|
<a href="/demo/" title="title">link</a>
|
||||||
|
```
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ docs/de-de/guide.md => http://domain.com/de-de/guide
|
|||||||
|
|
||||||
Als Standardeinstellung wird das Inhaltsverzeichnis in der Seitenleiste automatisch basierend auf vorhandenen Markdown Dateien generiert. Wenn du das seitliche Inhaltsverzeichnis anpassen willst, kannst du eine Datei namens `_sidebar.md` erstellen (vergleiche [das seitliche Inhaltsverzeichnis für diese Dokumentation](https://github.com/QingWei-Li/docsify/blob/master/docs/de-de/_sidebar.md) als Beispiel):
|
Als Standardeinstellung wird das Inhaltsverzeichnis in der Seitenleiste automatisch basierend auf vorhandenen Markdown Dateien generiert. Wenn du das seitliche Inhaltsverzeichnis anpassen willst, kannst du eine Datei namens `_sidebar.md` erstellen (vergleiche [das seitliche Inhaltsverzeichnis für diese Dokumentation](https://github.com/QingWei-Li/docsify/blob/master/docs/de-de/_sidebar.md) als Beispiel):
|
||||||
|
|
||||||
Als Erstes musst du `loadSidebar` auf **true** setzen, vergleiche [Einstellungen für das seitliche Inhaltsverzeichnis](/de-de/configuration#load-sidebar).
|
Als Erstes musst du `loadSidebar` auf **true** setzen, vergleiche [Einstellungen für das seitliche Inhaltsverzeichnis](configuration.md#load-sidebar).
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- index.html -->
|
<!-- index.html -->
|
||||||
@@ -46,7 +46,7 @@ Als Zweites erstellst du eine Datei namens `_sidebar.md`:
|
|||||||
<!-- docs/_sidebar.md -->
|
<!-- docs/_sidebar.md -->
|
||||||
|
|
||||||
- [Home](/)
|
- [Home](/)
|
||||||
- [Guide](/guide)
|
- [Guide](de-de/guide.md)
|
||||||
```
|
```
|
||||||
|
|
||||||
!> Solltest du Github Pages verwenden, musst du zusätzlich eine Datei namens `.nojekyll` in `./docs` erstellen, um zu verhindern, dass Github Dateien ignoriert, die mit einem Unterstrich anfangen.
|
!> Solltest du Github Pages verwenden, musst du zusätzlich eine Datei namens `.nojekyll` in `./docs` erstellen, um zu verhindern, dass Github Dateien ignoriert, die mit einem Unterstrich anfangen.
|
||||||
@@ -55,7 +55,7 @@ Als Zweites erstellst du eine Datei namens `_sidebar.md`:
|
|||||||
|
|
||||||
## Inhaltsverzeichnis
|
## Inhaltsverzeichnis
|
||||||
|
|
||||||
Eine angepasste Seitenleist kann auch automatisch ein Inhaltsverzeichnis generieren, indem ein `subMaxLevel` gesetzt wird, vergleiche [sub-max-level Einstellungen](/de-de/configuration#sub-max-level).
|
Eine angepasste Seitenleist kann auch automatisch ein Inhaltsverzeichnis generieren, indem ein `subMaxLevel` gesetzt wird, vergleiche [sub-max-level Einstellungen](configuration.md#sub-max-level).
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- index.html -->
|
<!-- index.html -->
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ Als Standardeinstellung werden Hyperlinks auf der aktuellen Seite erkannt und de
|
|||||||
noData: {
|
noData: {
|
||||||
'/de-de/': 'Keine Ergebnisse',
|
'/de-de/': 'Keine Ergebnisse',
|
||||||
'/': 'No Results'
|
'/': 'No Results'
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// Headline depth, 1 - 6
|
||||||
|
depth: 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ Nachdem der Befehl `init` vollständig ausgeführt wurde, kannst du folgende Dat
|
|||||||
* `README.md` als die Startseite für die Dokumentation
|
* `README.md` als die Startseite für die Dokumentation
|
||||||
* `.nojekyll` verhindert, dass Github Pages Dateien ignoriert, die mit einem Unterstrich beginnen.
|
* `.nojekyll` verhindert, dass Github Pages Dateien ignoriert, die mit einem Unterstrich beginnen.
|
||||||
|
|
||||||
Du kannst die Dokumentation über die Datei `./docs/README.md` nach Belieben ändern, und natürlich [weitere Seiten](/de-de/more-pages) hinzufügen.
|
Du kannst die Dokumentation über die Datei `./docs/README.md` nach Belieben ändern, und natürlich [weitere Seiten](de-de/more-pages.md) hinzufügen.
|
||||||
|
|
||||||
## Vorschau der eigenen Seiten
|
## Vorschau der eigenen Seiten
|
||||||
|
|
||||||
@@ -84,4 +84,4 @@ Du solltest das `data-app` Attribut anpassen, wenn du `el` geändert hast:
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
Vergleiche [el Einstellungen](/de-de/configuration#el).
|
Vergleiche [el Einstellungen](configuration.md#el).
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
# Server client renderer
|
||||||
|
|
||||||
|
See https://docsify.now.sh
|
||||||
|
|
||||||
|
Repo in https://github.com/QingWei-Li/docsify-ssr-demo
|
||||||
|
|
||||||
|
## Why SSR?
|
||||||
|
- Better SEO
|
||||||
|
- Feeling cool
|
||||||
|
|
||||||
|
## Quick start
|
||||||
|
|
||||||
|
Install `now` and `docsify-cli` in your project.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm i now docsify-cli -D
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit `package.json`. If the documentation in `./docs` subdirectory.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "my-project",
|
||||||
|
"scripts": {
|
||||||
|
"start": "docsify start . -c ssr.config.js",
|
||||||
|
"deploy": "now -p"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"docs"
|
||||||
|
],
|
||||||
|
"docsify": {
|
||||||
|
"config": {
|
||||||
|
"basePath": 'https://docsify.js.org/',
|
||||||
|
"loadSidebar": true,
|
||||||
|
"loadNavbar": true,
|
||||||
|
"coverpage": true,
|
||||||
|
"name": "docsify"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
!> The `basePath` just like webpack `publicPath`. We can use local or remote files.
|
||||||
|
|
||||||
|
We can preview in the local to see if it works.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
|
||||||
|
# open http://localhost:4000
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>docsify</title>
|
||||||
|
<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">
|
||||||
|
</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>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
The template should contain these comments for rendered app content.
|
||||||
|
- `<!--inject-app-->`
|
||||||
|
- `<!--inject-config-->`
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
You can configure it in a special config file, or `package.json`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
module.exports = {
|
||||||
|
template: './ssr.html',
|
||||||
|
config: {
|
||||||
|
// docsify config
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy for your VPS
|
||||||
|
|
||||||
|
You can run `docsify start` directly on your Node server, or write your own server app with `docsify-server-renderer`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var Renderer = require('docsify-server-renderer')
|
||||||
|
var readFileSync = require('fs').readFileSync
|
||||||
|
|
||||||
|
// init
|
||||||
|
var renderer = new Renderer({
|
||||||
|
template: readFileSync('./docs/index.template.html', 'utf-8').,
|
||||||
|
config: {
|
||||||
|
name: 'docsify',
|
||||||
|
repo: 'qingwei-li/docsify'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
renderer.renderToString(url)
|
||||||
|
.then(html => {})
|
||||||
|
.catch(err => {})
|
||||||
|
```
|
||||||
@@ -47,6 +47,8 @@ window.$docsify = {
|
|||||||
|
|
||||||
## Beispiel
|
## Beispiel
|
||||||
|
|
||||||
|
### footer
|
||||||
|
|
||||||
Füge jeder Seite eine footer Komponente hinzu:
|
Füge jeder Seite eine footer Komponente hinzu:
|
||||||
|
|
||||||
```js
|
```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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -25,3 +25,28 @@ General tips like:
|
|||||||
are rendered as:
|
are rendered as:
|
||||||
|
|
||||||
?> *TODO* unit test
|
?> *TODO* unit test
|
||||||
|
|
||||||
|
## Ignore to compile link
|
||||||
|
|
||||||
|
Some time we will put some other relative path to the link, you have to need to tell docsify you don't need to compile this link. For example
|
||||||
|
|
||||||
|
```md
|
||||||
|
[link](/demo/)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
It will be compiled to `<a href="/#/demo/">link</a>` and will be loaded `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.
|
||||||
|
|
||||||
|
Now you can do that
|
||||||
|
|
||||||
|
```md
|
||||||
|
[link](/demo/ ":ignore")
|
||||||
|
```
|
||||||
|
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set title for link.
|
||||||
|
|
||||||
|
```md
|
||||||
|
[link](/demo/ ":ignore title")
|
||||||
|
|
||||||
|
<a href="/demo/" title="title">link</a>
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
+28
-13
@@ -7,10 +7,10 @@
|
|||||||
<meta name="keywords" content="doc,docs,documentation,gitbook,creator,generator,github,jekyll,github-pages">
|
<meta name="keywords" content="doc,docs,documentation,gitbook,creator,generator,github,jekyll,github-pages">
|
||||||
<meta name="description" content="A magical documentation generator.">
|
<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">
|
<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="//cdn.jsdelivr.net/npm/docsify@latest/lib/themes/vue.css" title="vue">
|
||||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/dark.css" title="dark" disabled>
|
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@latest/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="//cdn.jsdelivr.net/npm/docsify@latest/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/pure.css" title="pure" disabled>
|
||||||
<style>
|
<style>
|
||||||
nav.app-nav li ul {
|
nav.app-nav li ul {
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
@@ -23,16 +23,17 @@
|
|||||||
<script>
|
<script>
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
alias: {
|
alias: {
|
||||||
'/de-de/changelog': '/changelog',
|
'.*?/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG',
|
||||||
'/zh-cn/changelog': '/changelog',
|
'/.*/_navbar.md': '/_navbar.md'
|
||||||
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
|
||||||
},
|
},
|
||||||
auto2top: true,
|
auto2top: true,
|
||||||
coverpage: true,
|
coverpage: true,
|
||||||
executeScript: true,
|
executeScript: true,
|
||||||
loadSidebar: true,
|
loadSidebar: true,
|
||||||
loadNavbar: true,
|
loadNavbar: true,
|
||||||
|
mergeNavbar: true,
|
||||||
maxLevel: 4,
|
maxLevel: 4,
|
||||||
|
subMaxLevel: 2,
|
||||||
name: 'docsify',
|
name: 'docsify',
|
||||||
search: {
|
search: {
|
||||||
noData: {
|
noData: {
|
||||||
@@ -47,12 +48,26 @@
|
|||||||
'/': 'Search'
|
'/': 'Search'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subMaxLevel: 2
|
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||||
|
plugins: [
|
||||||
|
function(hook, vm) {
|
||||||
|
hook.beforeEach(function (html) {
|
||||||
|
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>
|
||||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
<script src="//cdn.jsdelivr.net/npm/docsify@latest/lib/docsify.min.js"></script>
|
||||||
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
|
<script src="//cdn.jsdelivr.net/npm/docsify@latest/lib/plugins/search.min.js"></script>
|
||||||
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
|
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script>
|
||||||
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
|
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-markdown.min.js"></script>
|
||||||
<script src="//unpkg.com/prismjs/components/prism-nginx.min.js"></script>
|
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-nginx.min.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+9
-9
@@ -6,12 +6,12 @@ For example, the directory structure is as follows:
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
.
|
.
|
||||||
├── docs
|
└── docs
|
||||||
| └── README.md
|
├── README.md
|
||||||
| └── guide.md
|
├── guide.md
|
||||||
| └── zh-cn
|
└── zh-cn
|
||||||
| └──README.md
|
├── README.md
|
||||||
| └──guide.md
|
└── guide.md
|
||||||
```
|
```
|
||||||
|
|
||||||
Matching routes
|
Matching routes
|
||||||
@@ -27,7 +27,7 @@ docs/zh-cn/guide.md => http://domain.com/zh-cn/guide
|
|||||||
|
|
||||||
By default, the table of contents in the sidebar is automatically generated based on your markdown files. If you need a custom sidebar, then you can create your own `_sidebar.md` (see [this documentation's sidebar](https://github.com/QingWei-Li/docsify/blob/master/docs/_sidebar.md) for an example):
|
By default, the table of contents in the sidebar is automatically generated based on your markdown files. If you need a custom sidebar, then you can create your own `_sidebar.md` (see [this documentation's sidebar](https://github.com/QingWei-Li/docsify/blob/master/docs/_sidebar.md) for an example):
|
||||||
|
|
||||||
First, you need to set `loadSidebar` to **true**. Details are available in the [configuration paragraph](configuration#load-sidebar).
|
First, you need to set `loadSidebar` to **true**. Details are available in the [configuration paragraph](configuration.md#load-sidebar).
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- index.html -->
|
<!-- index.html -->
|
||||||
@@ -46,7 +46,7 @@ Create the `_sidebar.md`:
|
|||||||
<!-- docs/_sidebar.md -->
|
<!-- docs/_sidebar.md -->
|
||||||
|
|
||||||
- [Home](/)
|
- [Home](/)
|
||||||
- [Guide](/guide)
|
- [Guide](guide.md)
|
||||||
```
|
```
|
||||||
|
|
||||||
!> You need to create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
|
!> You need to create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
|
||||||
@@ -55,7 +55,7 @@ Create the `_sidebar.md`:
|
|||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
A custom sidebar can also automatically generate a table of contents by setting a `subMaxLevel`, compare [sub-max-level configuration](configuration#sub-max-level).
|
A custom sidebar can also automatically generate a table of contents by setting a `subMaxLevel`, compare [sub-max-level configuration](configuration.md#sub-max-level).
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- index.html -->
|
<!-- index.html -->
|
||||||
|
|||||||
+4
-1
@@ -35,7 +35,10 @@ By default, the hyperlink on the current page is recognized and the content is s
|
|||||||
noData: {
|
noData: {
|
||||||
'/zh-cn/': '找不到结果',
|
'/zh-cn/': '找不到结果',
|
||||||
'/': 'No Results'
|
'/': 'No Results'
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// Headline depth, 1 - 6
|
||||||
|
depth: 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@ After the `init` is complete, you can see the file list in the `./docs` subdirec
|
|||||||
* `README.md` as the home page
|
* `README.md` as the home page
|
||||||
* `.nojekyll` prevents GitHub Pages from ignoring files that begin with an underscore
|
* `.nojekyll` prevents GitHub Pages from ignoring files that begin with an underscore
|
||||||
|
|
||||||
You can easily update the documentation in `./docs/README.md`, of course you can add [more pages](more-pages).
|
You can easily update the documentation in `./docs/README.md`, of course you can add [more pages](more-pages.md).
|
||||||
|
|
||||||
## Preview your site
|
## Preview your site
|
||||||
|
|
||||||
@@ -84,4 +84,4 @@ You should set the `data-app` attribute if you changed `el`:
|
|||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
Compare [el configuration](/configuration#el).
|
Compare [el configuration](configuration.md#el).
|
||||||
|
|||||||
+123
@@ -0,0 +1,123 @@
|
|||||||
|
# Server client renderer
|
||||||
|
|
||||||
|
See https://docsify.now.sh
|
||||||
|
|
||||||
|
Repo in https://github.com/QingWei-Li/docsify-ssr-demo
|
||||||
|
|
||||||
|
## Why SSR?
|
||||||
|
- Better SEO
|
||||||
|
- Feeling cool
|
||||||
|
|
||||||
|
## Quick start
|
||||||
|
|
||||||
|
Install `now` and `docsify-cli` in your project.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm i now docsify-cli -D
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit `package.json`. If the documentation in `./docs` subdirectory.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "my-project",
|
||||||
|
"scripts": {
|
||||||
|
"start": "docsify start . -c ssr.config.js",
|
||||||
|
"deploy": "now -p"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"docs"
|
||||||
|
],
|
||||||
|
"docsify": {
|
||||||
|
"config": {
|
||||||
|
"basePath": 'https://docsify.js.org/',
|
||||||
|
"loadSidebar": true,
|
||||||
|
"loadNavbar": true,
|
||||||
|
"coverpage": true,
|
||||||
|
"name": "docsify"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
!> The `basePath` just like webpack `publicPath`. We can use local or remote files.
|
||||||
|
|
||||||
|
We can preview in the local to see if it works.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
|
||||||
|
# open http://localhost:4000
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>docsify</title>
|
||||||
|
<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">
|
||||||
|
</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>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
The template should contain these comments for rendered app content.
|
||||||
|
- `<!--inject-app-->`
|
||||||
|
- `<!--inject-config-->`
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
You can configure it in a special config file, or `package.json`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
module.exports = {
|
||||||
|
template: './ssr.html',
|
||||||
|
config: {
|
||||||
|
// docsify config
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy for your VPS
|
||||||
|
|
||||||
|
You can run `docsify start` directly on your Node server, or write your own server app with `docsify-server-renderer`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var Renderer = require('docsify-server-renderer')
|
||||||
|
var readFileSync = require('fs').readFileSync
|
||||||
|
|
||||||
|
// init
|
||||||
|
var renderer = new Renderer({
|
||||||
|
template: readFileSync('./docs/index.template.html', 'utf-8').,
|
||||||
|
config: {
|
||||||
|
name: 'docsify',
|
||||||
|
repo: 'qingwei-li/docsify'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
renderer.renderToString(url)
|
||||||
|
.then(html => {})
|
||||||
|
.catch(err => {})
|
||||||
|
```
|
||||||
@@ -47,6 +47,8 @@ window.$docsify = {
|
|||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
#### footer
|
||||||
|
|
||||||
Add footer component in each pages.
|
Add footer component in each pages.
|
||||||
|
|
||||||
```js
|
```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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -6,18 +6,19 @@
|
|||||||
|
|
||||||
docsify 是一个动态生成文档网站的工具。不同于 GitBook、Hexo 的地方是它不会生成将 `.md` 转成 `.html` 文件,所有转换工作都是在运行时进行。
|
docsify 是一个动态生成文档网站的工具。不同于 GitBook、Hexo 的地方是它不会生成将 `.md` 转成 `.html` 文件,所有转换工作都是在运行时进行。
|
||||||
|
|
||||||
这将非常实用,如果只是需要快速的搭建一个小型的文档网站,或者不想因为生成的一堆 `.html` 文件“污染” commit 记录,只需要创建一个 `index.html` 就可以开始写文档而且直接[部署在 GitHub Pages](zh-cn/deploy)。
|
这将非常实用,如果只是需要快速的搭建一个小型的文档网站,或者不想因为生成的一堆 `.html` 文件“污染” commit 记录,只需要创建一个 `index.html` 就可以开始写文档而且直接[部署在 GitHub Pages](zh-cn/deploy.md)。
|
||||||
|
|
||||||
查看[快速开始](zh-cn/quickstart)了解详情。
|
查看[快速开始](zh-cn/quickstart.md)了解详情。
|
||||||
|
|
||||||
## 特性
|
## 特性
|
||||||
- 无需构建,写完文档直接发布
|
- 无需构建,写完文档直接发布
|
||||||
- 容易使用并且轻量 (~16kB gzipped)
|
- 容易使用并且轻量 (~18kB gzipped)
|
||||||
- 智能的全文搜索
|
- 智能的全文搜索
|
||||||
- 提供多套主题
|
- 提供多套主题
|
||||||
- 丰富的 API
|
- 丰富的 API
|
||||||
- 支持 Emoji
|
- 支持 Emoji
|
||||||
- 兼容 IE10+
|
- 兼容 IE10+
|
||||||
|
- 支持 SSR ([example](https://github.com/QingWei-Li/docsify-ssr-demo))
|
||||||
|
|
||||||
## 例子
|
## 例子
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
- :cn:
|
|
||||||
- [:cn: 中文](/zh-cn/)
|
|
||||||
- [:de: German](/de-de/)
|
|
||||||
- [:uk: English](/)
|
|
||||||
+17
-16
@@ -1,22 +1,23 @@
|
|||||||
- 入门
|
- 入门
|
||||||
- [快速开始](zh-cn/quickstart)
|
- [快速开始](zh-cn/quickstart.md)
|
||||||
- [多页文档](zh-cn/more-pages)
|
- [多页文档](zh-cn/more-pages.md)
|
||||||
- [定制导航栏](zh-cn/custom-navbar)
|
- [定制导航栏](zh-cn/custom-navbar.md)
|
||||||
- [封面](zh-cn/cover)
|
- [封面](zh-cn/cover.md)
|
||||||
|
|
||||||
- 定制化
|
- 定制化
|
||||||
- [配置项](zh-cn/configuration)
|
- [配置项](zh-cn/configuration.md)
|
||||||
- [主题](zh-cn/themes)
|
- [主题](zh-cn/themes.md)
|
||||||
- [插件列表](zh-cn/plugins)
|
- [插件列表](zh-cn/plugins.md)
|
||||||
- [开发插件](zh-cn/write-a-plugin)
|
- [开发插件](zh-cn/write-a-plugin.md)
|
||||||
- [Markdown 配置](zh-cn/markdown)
|
- [Markdown 配置](zh-cn/markdown.md)
|
||||||
- [代码高亮](zh-cn/language-highlight)
|
- [代码高亮](zh-cn/language-highlight.md)
|
||||||
|
|
||||||
- 指南
|
- 指南
|
||||||
- [部署](zh-cn/deploy)
|
- [部署](zh-cn/deploy.md)
|
||||||
- [文档助手](zh-cn/helpers)
|
- [文档助手](zh-cn/helpers.md)
|
||||||
- [兼容 Vue](zh-cn/vue)
|
- [兼容 Vue](zh-cn/vue.md)
|
||||||
- [CDN](zh-cn/cdn)
|
- [CDN](zh-cn/cdn.md)
|
||||||
- [离线模式(PWA)](zh-cn/pwa)
|
- [离线模式(PWA)](zh-cn/pwa.md)
|
||||||
|
- [服务端渲染 (SSR)](zh-cn/ssr.md)
|
||||||
|
|
||||||
- [Changelog](zh-cn/changelog)
|
- [Changelog](zh-cn/changelog.md)
|
||||||
|
|||||||
+3
-2
@@ -44,5 +44,6 @@ JS 的压缩文件是原有文件路径的基础上加 `.min`后缀
|
|||||||
|
|
||||||
## 其他 CDN
|
## 其他 CDN
|
||||||
|
|
||||||
[jsDelivr](http://www.jsdelivr.com/projects/docsify) 也是可用的,具体用法参考其文档。
|
- http://www.bootcdn.cn/docsify (支持国内)
|
||||||
|
- https://cdn.jsdelivr.net/npm/docsify/ (国内外都支持)
|
||||||
|
- https://cdnjs.com/libraries/docsify
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ window.$docsify = {
|
|||||||
- 类型:`Boolean|String`
|
- 类型:`Boolean|String`
|
||||||
- 默认值: `false`
|
- 默认值: `false`
|
||||||
|
|
||||||
加载自定义导航栏,参考[定制导航栏](zh-cn/custom-navbar) 了解用法。设置为 `true` 后会加载 `_navbar.md` 文件,也可以自定义加载的文件名。
|
加载自定义导航栏,参考[定制导航栏](zh-cn/custom-navbar.md) 了解用法。设置为 `true` 后会加载 `_navbar.md` 文件,也可以自定义加载的文件名。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -91,7 +91,7 @@ window.$docsify = {
|
|||||||
- 类型:`Boolean|String`
|
- 类型:`Boolean|String`
|
||||||
- 默认值: `false`
|
- 默认值: `false`
|
||||||
|
|
||||||
加载自定义侧边栏,参考[多页文档](zh-cn/more-pages)。设置为 `true` 后会加载 `_sidebar.md` 文件,也可以自定义加载的文件名。
|
加载自定义侧边栏,参考[多页文档](zh-cn/more-pages.md)。设置为 `true` 后会加载 `_sidebar.md` 文件,也可以自定义加载的文件名。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -173,7 +173,7 @@ window.$docsify = {
|
|||||||
- 类型:`Boolean|String`
|
- 类型:`Boolean|String`
|
||||||
- 默认值: `false`
|
- 默认值: `false`
|
||||||
|
|
||||||
启用[封面页](/zh-cn/cover)。开启后是加载 `_coverpage.md` 文件,也可以自定义文件名。
|
启用[封面页](zh-cn/cover.md)。开启后是加载 `_coverpage.md` 文件,也可以自定义文件名。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -220,7 +220,7 @@ window.$docsify = {
|
|||||||
|
|
||||||
- 类型: `Object|Function`
|
- 类型: `Object|Function`
|
||||||
|
|
||||||
参考 [Markdown 配置](/zh-cn/markdown)。
|
参考 [Markdown 配置](zh-cn/markdown.md)。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -258,12 +258,13 @@ window.$docsify = {
|
|||||||
|
|
||||||
- 类型:`Object`
|
- 类型:`Object`
|
||||||
|
|
||||||
定义路由别名,可以更自由的定义路由规则。
|
定义路由别名,可以更自由的定义路由规则。 支持正则。
|
||||||
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
alias: {
|
alias: {
|
||||||
|
'/foo/(+*)': '/bar/$1', // supports regexp
|
||||||
'/zh-cn/changelog': '/changelog',
|
'/zh-cn/changelog': '/changelog',
|
||||||
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||||
}
|
}
|
||||||
@@ -287,7 +288,7 @@ window.$docsify = {
|
|||||||
|
|
||||||
- 类型:`Boolean`
|
- 类型:`Boolean`
|
||||||
|
|
||||||
执行文档里的 script 标签里的脚本,只执行第一个 script ([demo](zh-cn/themes))。 如果 Vue 存在,则自动开启。
|
执行文档里的 script 标签里的脚本,只执行第一个 script ([demo](zh-cn/themes.md))。 如果 Vue 存在,则自动开启。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
window.$docsify = {
|
window.$docsify = {
|
||||||
@@ -304,7 +305,7 @@ window.$docsify = {
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
注意如果执行的是一个外链脚本,比如 jsfiddle 的内嵌 demo,请确保引入 [external-script](zh-cn/plugins?id=外链脚本-external-script) 插件。
|
注意如果执行的是一个外链脚本,比如 jsfiddle 的内嵌 demo,请确保引入 [external-script](plugins.md?id=外链脚本-external-script) 插件。
|
||||||
|
|
||||||
## no-emoji
|
## no-emoji
|
||||||
|
|
||||||
@@ -315,3 +316,57 @@ window.$docsify = {
|
|||||||
noEmoji: true
|
noEmoji: true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## merge-navbar
|
||||||
|
|
||||||
|
小屏设备下合并导航栏到侧边栏。
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
mergeNavbar: true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## format-updated
|
||||||
|
|
||||||
|
我们可以显示文档更新日期通过 **{docsify-updated<span>}</span>** 变量. 并且格式化日期通过 `formatUpdated`.
|
||||||
|
参考 https://github.com/lukeed/tinydate#patterns
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
formatUpdated: '{MM}/{DD} {HH}:{mm}',
|
||||||
|
|
||||||
|
formatUpdated: function (time) {
|
||||||
|
// ...
|
||||||
|
|
||||||
|
return time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## external-link-target
|
||||||
|
|
||||||
|
Currently it defaults to _blank, would be nice if configurable:
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
externalLinkTarget: '_self' // default: '_blank'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## noCompileLinks
|
||||||
|
|
||||||
|
- type: `Array`
|
||||||
|
|
||||||
|
|
||||||
|
Sometimes we do not want docsify to handle our links. See [#203](https://github.com/QingWei-Li/docsify/issues/203)
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
noCompileLinks: [
|
||||||
|
'/foo',
|
||||||
|
'/bar/.*'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# 封面
|
# 封面
|
||||||
|
|
||||||
通过设置 `coverpage` 参数,可以开启渲染封面的功能。具体用法见[配置项#coverpage](zh-cn/configuration#coverpage)。
|
通过设置 `coverpage` 参数,可以开启渲染封面的功能。具体用法见[配置项#coverpage](configuration.md#coverpage)。
|
||||||
|
|
||||||
## 基本用法
|
## 基本用法
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
## 配置文件
|
## 配置文件
|
||||||
|
|
||||||
那我们可以通过 Markdown 文件来配置导航。首先配置 `loadNavbar`,默认加载的文件为 `_navbar.md`。具体配置规则见[配置项#load-navbar](zh-cn/configuration#load-navbar)。
|
那我们可以通过 Markdown 文件来配置导航。首先配置 `loadNavbar`,默认加载的文件为 `_navbar.md`。具体配置规则见[配置项#load-navbar](configuration.md#load-navbar)。
|
||||||
|
|
||||||
*index.html*
|
*index.html*
|
||||||
|
|
||||||
@@ -49,17 +49,17 @@
|
|||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
- 基础
|
- 基础
|
||||||
- [快速开始](zh-cn/quickstart)
|
- [快速开始](zh-cn/quickstart.md)
|
||||||
- [多页文档](zh-cn/more-pages)
|
- [多页文档](zh-cn/more-pages.md)
|
||||||
- [定制导航栏](zh-cn/custom-navbar)
|
- [定制导航栏](zh-cn/custom-navbar.md)
|
||||||
- [封面](zh-cn/cover)
|
- [封面](zh-cn/cover.md)
|
||||||
|
|
||||||
- 配置
|
- 配置
|
||||||
- [配置项](zh-cn/configuration)
|
- [配置项](zh-cn/configuration.md)
|
||||||
- [主题](zh-cn/themes)
|
- [主题](zh-cn/themes.md)
|
||||||
- [使用插件](zh-cn/plugins)
|
- [使用插件](zh-cn/plugins.md)
|
||||||
- [Markdown 配置](zh-cn/markdown)
|
- [Markdown 配置](zh-cn/markdown.md)
|
||||||
- [代码高亮](zh-cn/language-highlight)
|
- [代码高亮](zh-cn/language-highlight.md)
|
||||||
```
|
```
|
||||||
|
|
||||||
效果图
|
效果图
|
||||||
|
|||||||
@@ -24,3 +24,28 @@ docsify 扩展了一些 Markdown 语法,可以让文档更易读。
|
|||||||
|
|
||||||
?> *TODO* 完善示例
|
?> *TODO* 完善示例
|
||||||
|
|
||||||
|
|
||||||
|
## Ignore to compile link
|
||||||
|
|
||||||
|
Some time we will put some other relative path to the link, you have to need to tell docsify you don't need to compile this link. For example
|
||||||
|
|
||||||
|
```md
|
||||||
|
[link](/demo/)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
It will be compiled to `<a href="/#/demo/">link</a>` and will be loaded `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.
|
||||||
|
|
||||||
|
Now you can do that
|
||||||
|
|
||||||
|
```md
|
||||||
|
[link](/demo/ ":ignore")
|
||||||
|
```
|
||||||
|
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set title for link.
|
||||||
|
|
||||||
|
```md
|
||||||
|
[link](/demo/ ":ignore title")
|
||||||
|
|
||||||
|
<a href="/demo/" title="title">link</a>
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,4 @@
|
|||||||
<script src="//unpkg.com/prismjs/components/prism-php.js"></script>
|
<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)。
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ docs/zh-cn/guide.md => http://domain.com/zh-cn/guide
|
|||||||
|
|
||||||
默认情况下,侧边栏会根据当前文档的标题生成目录。也可以设置文档链接,通过 Markdown 文件生成,效果如当前的文档的侧边栏。
|
默认情况下,侧边栏会根据当前文档的标题生成目录。也可以设置文档链接,通过 Markdown 文件生成,效果如当前的文档的侧边栏。
|
||||||
|
|
||||||
首先配置 `loadSidebar` 选项,具体配置规则见[配置项#load-sidebar](zh-cn/configuration#load-sidebar)。
|
首先配置 `loadSidebar` 选项,具体配置规则见[配置项#load-sidebar](configuration.md#load-sidebar)。
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -35,7 +35,10 @@
|
|||||||
noData: {
|
noData: {
|
||||||
'/zh-cn/': '找不到结果',
|
'/zh-cn/': '找不到结果',
|
||||||
'/': 'No Results'
|
'/': 'No Results'
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// 搜索标题的最大程级, 1 - 6
|
||||||
|
depth: 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ docsify init ./docs
|
|||||||
- `README.md` 会做为主页内容渲染
|
- `README.md` 会做为主页内容渲染
|
||||||
- `.nojekyll` 用于阻止 GitHub Pages 会忽略掉下划线开头的文件
|
- `.nojekyll` 用于阻止 GitHub Pages 会忽略掉下划线开头的文件
|
||||||
|
|
||||||
直接编辑 `docs/README.md` 就能更新网站内容,当然也可以[写多个页面](zh-cn/more-pages)。
|
直接编辑 `docs/README.md` 就能更新网站内容,当然也可以[写多个页面](zh-cn/more-pages.md)。
|
||||||
|
|
||||||
## 本地预览网站
|
## 本地预览网站
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
# 服务端渲染(SSR)
|
||||||
|
|
||||||
|
先看例子 https://docsify.now.sh
|
||||||
|
|
||||||
|
项目地址在 https://github.com/QingWei-Li/docsify-ssr-demo
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
文档依旧是部署在 GitHub Pages 上,Node 服务部署在 now.sh 里,渲染的内容是从 GitHub Pages 上同步过来的。所以静态部署文档的服务器和服务端渲染的 Node 服务器是分开的,也就是说你还是可以用之前的方式更新文档,并不需要每次都部署。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
如果你熟悉 `now` 的使用,接下来的介绍就很简单了。先创建一个新项目,并安装 `now` 和 `docsify-cli`。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir my-ssr-demo && cd my-ssr-demo
|
||||||
|
npm init -y
|
||||||
|
npm i now docsify-cli -D
|
||||||
|
```
|
||||||
|
|
||||||
|
配置 `package.json`
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"start": "docsify start .",
|
||||||
|
"deploy": "now -p"
|
||||||
|
},
|
||||||
|
"docsify": {
|
||||||
|
"config": {
|
||||||
|
"basePath": "https://docsify.js.org/",
|
||||||
|
"loadSidebar": true,
|
||||||
|
"loadNavbar": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
如果你还没有创建文档,可以参考[之前的文章](https://zhuanlan.zhihu.com/p/24540753)。其中 `basePath` 为文档所在的路径,可以填你的 docsify 文档网站。
|
||||||
|
|
||||||
|
配置可以单独写在配置文件内,然后通过 `--config config.js` 加载。
|
||||||
|
|
||||||
|
渲染的基础模版也可以自定义,配置在 `template` 属性上,例如
|
||||||
|
|
||||||
|
```js
|
||||||
|
"docsify": {
|
||||||
|
"template": "./ssr.html",
|
||||||
|
"config": {
|
||||||
|
"basePath": "https://docsify.js.org/",
|
||||||
|
"loadSidebar": true,
|
||||||
|
"loadNavbar": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
*ssr.html*
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<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/lib/themes/vue.css" title="vue">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!--inject-app-->
|
||||||
|
<!--inject-config-->
|
||||||
|
</body>
|
||||||
|
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||||
|
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
其中 `<!--inject-app-->` 和 `<!--inject-config-->` 为占位符,会自动将渲染后的 html 和配置内容注入到页面上。
|
||||||
|
|
||||||
|
现在,你可以运行 `npm start` 预览效果,如果没有问题就通过 `npm run deploy` 部署服务。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
# open http://localhost:4000
|
||||||
|
|
||||||
|
npm run deploy
|
||||||
|
# now ...
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 更多玩法
|
||||||
|
|
||||||
|
`docsify start` 其实是依赖了 [`docsify-server-renderer`](https://npmarket.surge.sh/?name=docsify-server-renderer) 模块,如果你感兴趣,你完全可以用它自己实现一个 server,可以加入缓存等功能。
|
||||||
|
|
||||||
|
```js
|
||||||
|
var Renderer = require('docsify-server-renderer')
|
||||||
|
var readFileSync = require('fs').readFileSync
|
||||||
|
|
||||||
|
// init
|
||||||
|
var renderer = new Renderer({
|
||||||
|
template: readFileSync('./docs/index.template.html', 'utf-8').,
|
||||||
|
config: {
|
||||||
|
name: 'docsify',
|
||||||
|
repo: 'qingwei-li/docsify'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
renderer.renderToString(url)
|
||||||
|
.then(html => {})
|
||||||
|
.catch(err => {})
|
||||||
|
```
|
||||||
|
|
||||||
|
当然文档文件和 server 也是可以部署在一起的,`basePath` 不是一个 URL 的话就会当做文件路径处理,也就是从服务器上加载资源。
|
||||||
@@ -46,6 +46,9 @@ window.$docsify = {
|
|||||||
|
|
||||||
## 例子
|
## 例子
|
||||||
|
|
||||||
|
|
||||||
|
### footer
|
||||||
|
|
||||||
给每个页面的末尾加上 `footer`
|
给每个页面的末尾加上 `footer`
|
||||||
|
|
||||||
```js
|
```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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
```
|
```
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"lerna": "2.0.0-rc.5",
|
||||||
|
"packages": [
|
||||||
|
"packages/*"
|
||||||
|
],
|
||||||
|
"version": "0.0.0"
|
||||||
|
}
|
||||||
+865
-557
File diff suppressed because it is too large
Load Diff
Vendored
+2
-2
File diff suppressed because one or more lines are too long
@@ -1,4 +1,3 @@
|
|||||||
this.D = this.D || {};
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,18 +1,23 @@
|
|||||||
this.D = this.D || {};
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function handleExternalScript () {
|
function handleExternalScript () {
|
||||||
var container = Docsify.dom.getNode('#main');
|
var container = Docsify.dom.getNode('#main');
|
||||||
var script = Docsify.dom.find(container, 'script');
|
var scripts = Docsify.dom.findAll(container, 'script');
|
||||||
|
|
||||||
if (script && script.src) {
|
for (var i = scripts.length; i--;) {
|
||||||
var newScript = document.createElement('script');['src', 'async', 'defer'].forEach(function (attribute) {
|
var script = scripts[i];
|
||||||
newScript[attribute] = script[attribute];
|
|
||||||
});
|
|
||||||
|
|
||||||
script.parentNode.insertBefore(newScript, script);
|
if (script && script.src) {
|
||||||
script.parentNode.removeChild(script);
|
var newScript = document.createElement('script');
|
||||||
|
|
||||||
|
Array.prototype.slice.call(script.attributes).forEach(function (attribute) {
|
||||||
|
newScript[attribute.name] = attribute.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
script.parentNode.insertBefore(newScript, script);
|
||||||
|
script.parentNode.removeChild(script);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
this.D=this.D||{},function(){"use strict";function i(){var i=Docsify.dom.getNode("#main"),n=Docsify.dom.find(i,"script");if(n&&n.src){var o=document.createElement("script");["src","async","defer"].forEach(function(i){o[i]=n[i]}),n.parentNode.insertBefore(o,n),n.parentNode.removeChild(n)}}var n=function(n){n.doneEach(i)};window.$docsify.plugins=[].concat(n,window.$docsify.plugins)}();
|
!function(){"use strict";function e(){for(var e=Docsify.dom.getNode("#main"),o=Docsify.dom.findAll(e,"script"),n=o.length;n--;){var i=o[n];if(i&&i.src){var t=document.createElement("script");Array.prototype.slice.call(i.attributes).forEach(function(e){t[e.name]=e.value}),i.parentNode.insertBefore(t,i),i.parentNode.removeChild(i)}}}var o=function(o){o.doneEach(e)};window.$docsify.plugins=[].concat(o,window.$docsify.plugins)}();
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
this.D = this.D || {};
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -498,6 +497,6 @@ var install = function (hook, vm) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
window.$docsify.plugins = [].concat(install, window.$docsify.plugins);
|
$docsify.plugins = [].concat(install, $docsify.plugins);
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+13
-13
@@ -1,4 +1,3 @@
|
|||||||
this.D = this.D || {};
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -11,24 +10,25 @@ function appendScript () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init (id) {
|
function init (id) {
|
||||||
if (!window.ga) {
|
appendScript();
|
||||||
appendScript();
|
window.ga = window.ga || function () {
|
||||||
window.ga = window.ga || function () {
|
(window.ga.q = window.ga.q || []).push(arguments);
|
||||||
(window.ga.q = window.ga.q || []).push(arguments);
|
};
|
||||||
};
|
window.ga.l = Number(new Date());
|
||||||
window.ga.l = Number(new Date());
|
window.ga('create', id, 'auto');
|
||||||
window.ga('create', id, 'auto');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function collect () {
|
function collect () {
|
||||||
init(window.$docsify.ga);
|
if (!window.ga) {
|
||||||
window.ga('set', 'page', location.href);
|
init($docsify.ga);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.ga('set', 'page', location.hash);
|
||||||
window.ga('send', 'pageview');
|
window.ga('send', 'pageview');
|
||||||
}
|
}
|
||||||
|
|
||||||
var install = function (hook) {
|
var install = function (hook) {
|
||||||
if (!window.$docsify.ga) {
|
if (!$docsify.ga) {
|
||||||
console.error('[Docsify] ga is required.');
|
console.error('[Docsify] ga is required.');
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,6 @@ var install = function (hook) {
|
|||||||
hook.beforeEach(collect);
|
hook.beforeEach(collect);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.$docsify.plugins = [].concat(install, window.$docsify.plugins);
|
$docsify.plugins = [].concat(install, $docsify.plugins);
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|||||||
Vendored
+1
-1
@@ -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 o(o){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",o,"auto"))}function i(){o(window.$docsify.ga),window.ga("set","page",location.href),window.ga("send","pageview")}var w=function(n){return window.$docsify.ga?void n.beforeEach(i):void console.error("[Docsify] ga is required.")};window.$docsify.plugins=[].concat(w,window.$docsify.plugins)}();
|
!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 o(o){n(),window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=Number(new Date),window.ga("create",o,"auto")}function i(){window.ga||o($docsify.ga),window.ga("set","page",location.hash),window.ga("send","pageview")}var a=function(n){if(!$docsify.ga)return void console.error("[Docsify] ga is required.");n.beforeEach(i)};$docsify.plugins=[].concat(a,$docsify.plugins)}();
|
||||||
|
|||||||
+56
-49
@@ -1,4 +1,3 @@
|
|||||||
this.D = this.D || {};
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -18,18 +17,18 @@ 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 () {
|
function getAllPaths (router) {
|
||||||
var paths = [];
|
var paths = [];
|
||||||
|
|
||||||
helper.dom.findAll('a:not([data-nosearch])')
|
helper.dom.findAll('a:not([data-nosearch])')
|
||||||
.map(function (node) {
|
.map(function (node) {
|
||||||
var href = node.href;
|
var href = node.href;
|
||||||
var originHref = node.getAttribute('href');
|
var originHref = node.getAttribute('href');
|
||||||
var path = helper.route.parse(href).path;
|
var path = router.parse(href).path;
|
||||||
|
|
||||||
if (path &&
|
if (path &&
|
||||||
paths.indexOf(path) === -1 &&
|
paths.indexOf(path) === -1 &&
|
||||||
!helper.route.isAbsolutePath(originHref)) {
|
!Docsify.util.isAbsolutePath(originHref)) {
|
||||||
paths.push(path);
|
paths.push(path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -42,18 +41,17 @@ function saveData (maxAge) {
|
|||||||
localStorage.setItem('docsify.search.index', JSON.stringify(INDEXS));
|
localStorage.setItem('docsify.search.index', JSON.stringify(INDEXS));
|
||||||
}
|
}
|
||||||
|
|
||||||
function genIndex (path, content) {
|
function genIndex (path, content, router, depth) {
|
||||||
if ( content === void 0 ) content = '';
|
if ( content === void 0 ) content = '';
|
||||||
|
|
||||||
var tokens = window.marked.lexer(content);
|
var tokens = window.marked.lexer(content);
|
||||||
var slugify = window.Docsify.slugify;
|
var slugify = window.Docsify.slugify;
|
||||||
var toURL = Docsify.route.toURL;
|
|
||||||
var index = {};
|
var index = {};
|
||||||
var slug;
|
var slug;
|
||||||
|
|
||||||
tokens.forEach(function (token) {
|
tokens.forEach(function (token) {
|
||||||
if (token.type === 'heading' && token.depth <= 2) {
|
if (token.type === 'heading' && token.depth <= depth) {
|
||||||
slug = toURL(path, { id: slugify(token.text) });
|
slug = router.toURL(path, { id: slugify(token.text) });
|
||||||
index[slug] = { slug: slug, title: token.text, body: '' };
|
index[slug] = { slug: slug, title: token.text, body: '' };
|
||||||
} else {
|
} else {
|
||||||
if (!slug) { return }
|
if (!slug) { return }
|
||||||
@@ -153,7 +151,7 @@ function init$1 (config, vm) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var paths = isAuto ? getAllPaths() : config.paths;
|
var paths = isAuto ? getAllPaths(vm.router) : config.paths;
|
||||||
var len = paths.length;
|
var len = paths.length;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
@@ -161,73 +159,78 @@ function init$1 (config, vm) {
|
|||||||
if (INDEXS[path]) { return count++ }
|
if (INDEXS[path]) { return count++ }
|
||||||
|
|
||||||
helper
|
helper
|
||||||
.get(vm.$getFile(path))
|
.get(vm.router.getFile(path))
|
||||||
.then(function (result) {
|
.then(function (result) {
|
||||||
INDEXS[path] = genIndex(path, result);
|
INDEXS[path] = genIndex(path, result, vm.router, config.depth);
|
||||||
len === ++count && saveData(config.maxAge);
|
len === ++count && saveData(config.maxAge);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var dom;
|
|
||||||
var NO_DATA_TEXT = '';
|
var NO_DATA_TEXT = '';
|
||||||
|
|
||||||
function style () {
|
function style () {
|
||||||
var code = "\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}";
|
var code = "\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}";
|
||||||
var style = dom.create('style', code);
|
var style = Docsify.dom.create('style', code);
|
||||||
dom.appendTo(dom.head, style);
|
Docsify.dom.appendTo(Docsify.dom.head, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tpl (opts) {
|
function tpl (opts, defaultValue) {
|
||||||
|
if ( defaultValue === void 0 ) defaultValue = '';
|
||||||
|
|
||||||
var html =
|
var html =
|
||||||
"<input type=\"search\" />" +
|
"<input type=\"search\" value=\"" + defaultValue + "\" />" +
|
||||||
'<div class="results-panel"></div>' +
|
'<div class="results-panel"></div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
var el = dom.create('div', html);
|
var el = Docsify.dom.create('div', html);
|
||||||
var aside = dom.find('aside');
|
var aside = Docsify.dom.find('aside');
|
||||||
|
|
||||||
dom.toggleClass(el, 'search');
|
Docsify.dom.toggleClass(el, 'search');
|
||||||
dom.before(aside, el);
|
Docsify.dom.before(aside, el);
|
||||||
|
}
|
||||||
|
|
||||||
|
function doSearch (value) {
|
||||||
|
var $search = Docsify.dom.find('div.search');
|
||||||
|
var $panel = Docsify.dom.find($search, '.results-panel');
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
$panel.classList.remove('show');
|
||||||
|
$panel.innerHTML = '';
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var matchs = search(value);
|
||||||
|
|
||||||
|
var html = '';
|
||||||
|
matchs.forEach(function (post) {
|
||||||
|
html += "<div class=\"matching-post\">\n<h2><a href=\"" + (post.url) + "\">" + (post.title) + "</a></h2>\n<p>" + (post.content) + "</p>\n</div>";
|
||||||
|
});
|
||||||
|
|
||||||
|
$panel.classList.add('show');
|
||||||
|
$panel.innerHTML = html || ("<p class=\"empty\">" + NO_DATA_TEXT + "</p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindEvents () {
|
function bindEvents () {
|
||||||
var $search = dom.find('div.search');
|
var $search = Docsify.dom.find('div.search');
|
||||||
var $input = dom.find($search, 'input');
|
var $input = Docsify.dom.find($search, 'input');
|
||||||
var $panel = dom.find($search, '.results-panel');
|
|
||||||
var doSearch = function (value) {
|
|
||||||
if (!value) {
|
|
||||||
$panel.classList.remove('show');
|
|
||||||
$panel.innerHTML = '';
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var matchs = search(value);
|
|
||||||
|
|
||||||
var html = '';
|
|
||||||
matchs.forEach(function (post) {
|
|
||||||
html += "<div class=\"matching-post\">\n <h2><a href=\"" + (post.url) + "\">" + (post.title) + "</a></h2>\n <p>" + (post.content) + "</p>\n</div>";
|
|
||||||
});
|
|
||||||
|
|
||||||
$panel.classList.add('show');
|
|
||||||
$panel.innerHTML = html || ("<p class=\"empty\">" + NO_DATA_TEXT + "</p>");
|
|
||||||
};
|
|
||||||
|
|
||||||
var timeId;
|
var timeId;
|
||||||
// Prevent to Fold sidebar
|
// Prevent to Fold sidebar
|
||||||
dom.on($search, 'click',
|
Docsify.dom.on($search, 'click',
|
||||||
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); });
|
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); });
|
||||||
dom.on($input, 'input', function (e) {
|
Docsify.dom.on($input, 'input', function (e) {
|
||||||
clearTimeout(timeId);
|
clearTimeout(timeId);
|
||||||
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
|
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePlaceholder (text, path) {
|
function updatePlaceholder (text, path) {
|
||||||
var $input = dom.getNode('.search input[type="search"]');
|
var $input = Docsify.dom.getNode('.search input[type="search"]');
|
||||||
|
|
||||||
|
if (!$input) { return }
|
||||||
if (typeof text === 'string') {
|
if (typeof text === 'string') {
|
||||||
$input.placeholder = text;
|
$input.placeholder = text;
|
||||||
} else {
|
} else {
|
||||||
var match = Object.keys(text).find(function (key) { return path.indexOf(key) > -1; });
|
var match = Object.keys(text).filter(function (key) { return path.indexOf(key) > -1; })[0];
|
||||||
$input.placeholder = text[match];
|
$input.placeholder = text[match];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,16 +239,18 @@ function updateNoData (text, path) {
|
|||||||
if (typeof text === 'string') {
|
if (typeof text === 'string') {
|
||||||
NO_DATA_TEXT = text;
|
NO_DATA_TEXT = text;
|
||||||
} else {
|
} else {
|
||||||
var match = Object.keys(text).find(function (key) { return path.indexOf(key) > -1; });
|
var match = Object.keys(text).filter(function (key) { return path.indexOf(key) > -1; })[0];
|
||||||
NO_DATA_TEXT = text[match];
|
NO_DATA_TEXT = text[match];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init$$1 (opts) {
|
function init$$1 (opts, vm) {
|
||||||
dom = Docsify.dom;
|
var keywords = vm.router.parse().query.s;
|
||||||
|
|
||||||
style();
|
style();
|
||||||
tpl(opts);
|
tpl(opts, keywords);
|
||||||
bindEvents();
|
bindEvents();
|
||||||
|
keywords && setTimeout(function (_) { return doSearch(keywords); }, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update (opts, vm) {
|
function update (opts, vm) {
|
||||||
@@ -257,6 +262,7 @@ var CONFIG = {
|
|||||||
placeholder: 'Type to search',
|
placeholder: 'Type to search',
|
||||||
noData: 'No Results!',
|
noData: 'No Results!',
|
||||||
paths: 'auto',
|
paths: 'auto',
|
||||||
|
depth: 2,
|
||||||
maxAge: 86400000 // 1 day
|
maxAge: 86400000 // 1 day
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,12 +277,13 @@ var install = function (hook, vm) {
|
|||||||
CONFIG.maxAge = util.isPrimitive(opts.maxAge) ? opts.maxAge : CONFIG.maxAge;
|
CONFIG.maxAge = util.isPrimitive(opts.maxAge) ? opts.maxAge : CONFIG.maxAge;
|
||||||
CONFIG.placeholder = opts.placeholder || CONFIG.placeholder;
|
CONFIG.placeholder = opts.placeholder || CONFIG.placeholder;
|
||||||
CONFIG.noData = opts.noData || CONFIG.noData;
|
CONFIG.noData = opts.noData || CONFIG.noData;
|
||||||
|
CONFIG.depth = opts.depth || CONFIG.depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isAuto = CONFIG.paths === 'auto';
|
var isAuto = CONFIG.paths === 'auto';
|
||||||
|
|
||||||
hook.mounted(function (_) {
|
hook.mounted(function (_) {
|
||||||
init$$1(CONFIG);
|
init$$1(CONFIG, vm);
|
||||||
!isAuto && init$1(CONFIG, vm);
|
!isAuto && init$1(CONFIG, vm);
|
||||||
});
|
});
|
||||||
hook.doneEach(function (_) {
|
hook.doneEach(function (_) {
|
||||||
@@ -285,6 +292,6 @@ var install = function (hook, vm) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
window.$docsify.plugins = [].concat(install, window.$docsify.plugins);
|
$docsify.plugins = [].concat(install, $docsify.plugins);
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
this.D=this.D||{},function(){"use strict";function n(n){var e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(n).replace(/[&<>"'\/]/g,function(n){return e[n]})}function e(){var n=[];return d.dom.findAll("a:not([data-nosearch])").map(function(e){var t=e.href,a=e.getAttribute("href"),o=d.route.parse(t).path;o&&n.indexOf(o)===-1&&!d.route.isAbsolutePath(a)&&n.push(o)}),n}function t(n){localStorage.setItem("docsify.search.expires",Date.now()+n),localStorage.setItem("docsify.search.index",JSON.stringify(g))}function a(n,e){void 0===e&&(e="");var t,a=window.marked.lexer(e),o=window.Docsify.slugify,r=Docsify.route.toURL,i={};return a.forEach(function(e){if("heading"===e.type&&e.depth<=2)t=r(n,{id:o(e.text)}),i[t]={slug:t,title:e.text,body:""};else{if(!t)return;i[t]?i[t].body?i[t].body+="\n"+(e.text||""):i[t].body=e.text:i[t]={slug:t,title:"",body:""}}}),o.clear(),i}function o(e){var t=[],a=[];Object.keys(g).forEach(function(n){a=a.concat(Object.keys(g[n]).map(function(e){return g[n][e]}))}),e=[].concat(e,e.trim().split(/[\s\-\,\\\/]+/));for(var o=function(o){var r=a[o],i=!1,s="",c=r.title&&r.title.trim(),l=r.body&&r.body.trim(),p=r.slug||"";if(c&&l&&(e.forEach(function(e,t){var a=new RegExp(e,"gi"),o=-1,r=-1;if(o=c&&c.search(a),r=l&&l.search(a),o<0&&r<0)i=!1;else{i=!0,r<0&&(r=0);var p=0,u=0;p=r<11?0:r-10,u=0===p?70:r+e.length+60,u>l.length&&(u=l.length);var f="..."+n(l).substring(p,u).replace(a,'<em class="search-keyword">'+e+"</em>")+"...";s+=f}}),i)){var u={title:n(c),content:s,url:p};t.push(u)}},r=0;r<a.length;r++)o(r);return t}function r(n,o){d=Docsify;var r="auto"===n.paths,i=localStorage.getItem("docsify.search.expires")<Date.now();if(g=JSON.parse(localStorage.getItem("docsify.search.index")),i)g={};else if(!r)return;var s=r?e():n.paths,c=s.length,l=0;s.forEach(function(e){return g[e]?l++:void d.get(o.$getFile(e)).then(function(o){g[e]=a(e,o),c===++l&&t(n.maxAge)})})}function i(){var n="\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}",e=h.create("style",n);h.appendTo(h.head,e)}function s(n){var e='<input type="search" /><div class="results-panel"></div></div>',t=h.create("div",e),a=h.find("aside");h.toggleClass(t,"search"),h.before(a,t)}function c(){var n,e=h.find("div.search"),t=h.find(e,"input"),a=h.find(e,".results-panel"),r=function(n){if(!n)return a.classList.remove("show"),void(a.innerHTML="");var e=o(n),t="";e.forEach(function(n){t+='<div class="matching-post">\n <h2><a href="'+n.url+'">'+n.title+"</a></h2>\n <p>"+n.content+"</p>\n</div>"}),a.classList.add("show"),a.innerHTML=t||'<p class="empty">'+y+"</p>"};h.on(e,"click",function(n){return"A"!==n.target.tagName&&n.stopPropagation()}),h.on(t,"input",function(e){clearTimeout(n),n=setTimeout(function(n){return r(e.target.value.trim())},100)})}function l(n,e){var t=h.getNode('.search input[type="search"]');if("string"==typeof n)t.placeholder=n;else{var a=Object.keys(n).find(function(n){return e.indexOf(n)>-1});t.placeholder=n[a]}}function p(n,e){if("string"==typeof n)y=n;else{var t=Object.keys(n).find(function(n){return e.indexOf(n)>-1});y=n[t]}}function u(n){h=Docsify.dom,i(),s(n),c()}function f(n,e){l(n.placeholder,e.route.path),p(n.noData,e.route.path)}var d,h,g={},y="",m={placeholder:"Type to search",noData:"No Results!",paths:"auto",maxAge:864e5},v=function(n,e){var t=Docsify.util,a=e.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 o="auto"===m.paths;n.mounted(function(n){u(m),!o&&r(m,e)}),n.doneEach(function(n){f(m,e),o&&r(m,e)})};window.$docsify.plugins=[].concat(v,window.$docsify.plugins)}();
|
!function(){"use strict";function e(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(e){var n=[];return h.dom.findAll("a:not([data-nosearch])").map(function(t){var o=t.href,i=t.getAttribute("href"),r=e.parse(o).path;r&&-1===n.indexOf(r)&&!Docsify.util.isAbsolutePath(i)&&n.push(r)}),n}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(y))}function o(e,n,t,o){void 0===n&&(n="");var i,r=window.marked.lexer(n),a=window.Docsify.slugify,s={};return r.forEach(function(n){if("heading"===n.type&&n.depth<=o)i=t.toURL(e,{id:a(n.text)}),s[i]={slug:i,title:n.text,body:""};else{if(!i)return;s[i]?s[i].body?s[i].body+="\n"+(n.text||""):s[i].body=n.text:s[i]={slug:i,title:"",body:""}}}),a.clear(),s}function i(n){var t=[],o=[];Object.keys(y).forEach(function(e){o=o.concat(Object.keys(y[e]).map(function(n){return y[e][n]}))}),n=[].concat(n,n.trim().split(/[\s\-\,\\\/]+/));for(var i=0;i<o.length;i++)!function(i){var r=o[i],a=!1,s="",c=r.title&&r.title.trim(),f=r.body&&r.body.trim(),l=r.slug||"";if(c&&f&&(n.forEach(function(n,t){var o=new RegExp(n,"gi"),i=-1,r=-1;if(i=c&&c.search(o),r=f&&f.search(o),i<0&&r<0)a=!1;else{a=!0,r<0&&(r=0);var l=0,d=0;l=r<11?0:r-10,d=0===l?70:r+n.length+60,d>f.length&&(d=f.length);var p="..."+e(f).substring(l,d).replace(o,'<em class="search-keyword">'+n+"</em>")+"...";s+=p}}),a)){var d={title:e(c),content:s,url:l};t.push(d)}}(i);return t}function r(e,i){h=Docsify;var r="auto"===e.paths,a=localStorage.getItem("docsify.search.expires")<Date.now();if(y=JSON.parse(localStorage.getItem("docsify.search.index")),a)y={};else if(!r)return;var s=r?n(i.router):e.paths,c=s.length,f=0;s.forEach(function(n){if(y[n])return f++;h.get(i.router.getFile(n)).then(function(r){y[n]=o(n,r,i.router,e.depth),c===++f&&t(e.maxAge)})})}function a(){var e=Docsify.dom.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}");Docsify.dom.appendTo(Docsify.dom.head,e)}function s(e,n){void 0===n&&(n="");var t='<input type="search" value="'+n+'" /><div class="results-panel"></div></div>',o=Docsify.dom.create("div",t),i=Docsify.dom.find("aside");Docsify.dom.toggleClass(o,"search"),Docsify.dom.before(i,o)}function c(e){var n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,".results-panel");if(!e)return t.classList.remove("show"),void(t.innerHTML="");var o=i(e),r="";o.forEach(function(e){r+='<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=r||'<p class="empty">'+m+"</p>"}function f(){var e,n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,"input");Docsify.dom.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),Docsify.dom.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return c(n.target.value.trim())},100)})}function l(e,n){var t=Docsify.dom.getNode('.search input[type="search"]');if(t)if("string"==typeof e)t.placeholder=e;else{var o=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];t.placeholder=e[o]}}function d(e,n){if("string"==typeof e)m=e;else{var t=Object.keys(e).filter(function(e){return n.indexOf(e)>-1})[0];m=e[t]}}function p(e,n){var t=n.router.parse().query.s;a(),s(e,t),f(),t&&setTimeout(function(e){return c(t)},500)}function u(e,n){l(e.placeholder,n.route.path),d(e.noData,n.route.path)}var h,y={},m="",g={placeholder:"Type to search",noData:"No Results!",paths:"auto",depth:2,maxAge:864e5},v=function(e,n){var t=Docsify.util,o=n.config.search||g;Array.isArray(o)?g.paths=o:"object"==typeof o&&(g.paths=Array.isArray(o.paths)?o.paths:"auto",g.maxAge=t.isPrimitive(o.maxAge)?o.maxAge:g.maxAge,g.placeholder=o.placeholder||g.placeholder,g.noData=o.noData||g.noData,g.depth=o.depth||g.depth);var i="auto"===g.paths;e.mounted(function(e){p(g,n),!i&&r(g,n)}),e.doneEach(function(e){u(g,n),i&&r(g,n)})};$docsify.plugins=[].concat(v,$docsify.plugins)}();
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
this.D = this.D || {};
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
this.D=this.D||{},function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t){var e,n=Docsify.dom;n.appendTo(n.head,n.create("style",i)),t.doneEach(function(t){var i=n.findAll("img:not(.emoji)");Array.isArray(e)&&e.length&&(e.forEach(function(t){return t()}),e=[]),e=i.map(o)})}var n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o=t(function(t,e){!function(e,n){t.exports=n()}(n,function(){function t(){g===-1&&(g=window.pageYOffset);var t=Math.abs(g-window.pageYOffset);t>=40&&a()}function e(t){27===t.keyCode&&a()}function n(t){var e=t.touches[0];null!==e&&(y=e.pageY,t.target.addEventListener("touchmove",o))}function o(t){var e=t.touches[0];null!==e&&Math.abs(e.pageY-y)>10&&(a(),t.target.removeEventListener("touchmove",o))}function i(){a()}function r(){document.addEventListener("scroll",t),document.addEventListener("keyup",e),document.addEventListener("touchstart",n),document.addEventListener("click",i,!0)}function s(){document.removeEventListener("scroll",t),document.removeEventListener("keyup",e),document.removeEventListener("touchstart",n),document.removeEventListener("click",i,!0)}function a(t){null!==h&&(t?h.dispose():h.close(),s(),h=null)}function c(t){if(!document.body.classList.contains("zoom-overlay-open"))return t.metaKey||t.ctrlKey?void window.open(t.target.getAttribute("data-original")||t.target.src,"_blank"):void(t.target.width>=m()-v||(a(!0),h=new p(t.target,v),h.zoom(),r()))}var m=function(){return document.documentElement.clientWidth},u=function(){return document.documentElement.clientHeight},d=function(t){var e=t.getBoundingClientRect(),n=document.documentElement,o=window;return{top:e.top+o.pageYOffset-n.clientTop,left:e.left+o.pageXOffset-n.clientLeft}},l=function(t,e,n){var o=function(t){t.target.removeEventListener(e,o),n()};t.addEventListener(e,o)},f=function(t,e){this.w=t,this.h=e},p=function(t,e){this.img=t,this.preservedTransform=t.style.transform,this.wrap=null,this.overlay=null,this.offset=e};p.prototype.forceRepaint=function(){this.img.offsetWidth},p.prototype.zoom=function(){var t=new f(this.img.naturalWidth,this.img.naturalHeight);this.wrap=document.createElement("div"),this.wrap.classList.add("zoom-img-wrap"),this.img.parentNode.insertBefore(this.wrap,this.img),this.wrap.appendChild(this.img),this.img.classList.add("zoom-img"),this.img.setAttribute("data-action","zoom-out"),this.overlay=document.createElement("div"),this.overlay.classList.add("zoom-overlay"),document.body.appendChild(this.overlay),this.forceRepaint();var e=this.calculateScale(t);this.forceRepaint(),this.animate(e),document.body.classList.add("zoom-overlay-open")},p.prototype.calculateScale=function(t){var e=t.w/this.img.width,n=m()-this.offset,o=u()-this.offset,i=t.w/t.h,r=n/o;return t.w<n&&t.h<o?e:i<r?o/t.h*e:n/t.w*e},p.prototype.animate=function(t){var e=d(this.img),n=window.pageYOffset,o=m()/2,i=n+u()/2,r=e.left+this.img.width/2,s=e.top+this.img.height/2,a=o-r,c=i-s,l=0,f="scale("+t+")",p="translate3d("+a+"px, "+c+"px, "+l+"px)";this.img.style.transform=f,this.wrap.style.transform=p},p.prototype.dispose=function(){null!==this.wrap&&null!==this.wrap.parentNode&&(this.img.classList.remove("zoom-img"),this.img.setAttribute("data-action","zoom"),this.wrap.parentNode.insertBefore(this.img,this.wrap),this.wrap.parentNode.removeChild(this.wrap),document.body.removeChild(this.overlay),document.body.classList.remove("zoom-overlay-transitioning"))},p.prototype.close=function(){var t=this;document.body.classList.add("zoom-overlay-transitioning"),this.img.style.transform=this.preservedTransform,0===this.img.style.length&&this.img.removeAttribute("style"),this.wrap.style.transform="none",l(this.img,"transitionend",function(){t.dispose(),document.body.classList.remove("zoom-overlay-open")})};var h=null,v=80,g=-1,y=-1,w=function(t){return t.setAttribute("data-action","zoom"),t.addEventListener("click",c),function(){return t.removeEventListener("click",c)}};return w})}),i='img[data-action="zoom"] {\n cursor: pointer;\n cursor: -webkit-zoom-in;\n cursor: zoom-in;\n}\n.zoom-img,\n.zoom-img-wrap {\n position: relative;\n z-index: 666;\n transition: -webkit-transform 300ms cubic-bezier(.2,0,.2,1);\n transition: transform 300ms cubic-bezier(.2,0,.2,1);\n transition: transform 300ms cubic-bezier(.2,0,.2,1), -webkit-transform 300ms cubic-bezier(.2,0,.2,1);\n}\n.zoom-overlay {\n z-index: 420;\n background: #fff;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n opacity: 0;\n transition: opacity 300ms;\n}\n.zoom-overlay-open .zoom-overlay {\n opacity: 1;\n}\n.zoom-overlay-open {\n cursor: pointer;\n cursor: -webkit-zoom-out;\n cursor: zoom-out;\n}\n.zoom-overlay-transitioning {\n cursor: default;\n}\n.zoom-overlay-open.zoom-overlay-transitioning .zoom-overlay{\n opacity: 0;\n}\n';$docsify.plugins=[].concat(e,$docsify.plugins)}();
|
!function(){"use strict";function t(t){var o,i=Docsify.dom;i.appendTo(i.head,i.create("style",n)),t.doneEach(function(t){var n=i.findAll("img:not(.emoji)");Array.isArray(o)&&o.length&&(o.forEach(function(t){return t()}),o=[]),o=n.map(e)})}var e=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self,function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t,e){!function(e,n){t.exports=function(){function t(){-1===g&&(g=window.pageYOffset),Math.abs(g-window.pageYOffset)>=40&&a()}function e(t){27===t.keyCode&&a()}function n(t){var e=t.touches[0];null!==e&&(y=e.pageY,t.target.addEventListener("touchmove",o))}function o(t){var e=t.touches[0];null!==e&&Math.abs(e.pageY-y)>10&&(a(),t.target.removeEventListener("touchmove",o))}function i(){a()}function r(){document.addEventListener("scroll",t),document.addEventListener("keyup",e),document.addEventListener("touchstart",n),document.addEventListener("click",i,!0)}function s(){document.removeEventListener("scroll",t),document.removeEventListener("keyup",e),document.removeEventListener("touchstart",n),document.removeEventListener("click",i,!0)}function a(t){null!==h&&(t?h.dispose():h.close(),s(),h=null)}function c(t){if(!document.body.classList.contains("zoom-overlay-open"))return t.metaKey||t.ctrlKey?void window.open(t.target.getAttribute("data-original")||t.target.src,"_blank"):void(t.target.width>=m()-v||(a(!0),h=new p(t.target,v),h.zoom(),r()))}var m=function(){return document.documentElement.clientWidth},u=function(){return document.documentElement.clientHeight},d=function(t){var e=t.getBoundingClientRect(),n=document.documentElement,o=window;return{top:e.top+o.pageYOffset-n.clientTop,left:e.left+o.pageXOffset-n.clientLeft}},l=function(t,e,n){var o=function(t){t.target.removeEventListener(e,o),n()};t.addEventListener(e,o)},f=function(t,e){this.w=t,this.h=e},p=function(t,e){this.img=t,this.preservedTransform=t.style.transform,this.wrap=null,this.overlay=null,this.offset=e};p.prototype.forceRepaint=function(){this.img.offsetWidth},p.prototype.zoom=function(){var t=new f(this.img.naturalWidth,this.img.naturalHeight);this.wrap=document.createElement("div"),this.wrap.classList.add("zoom-img-wrap"),this.img.parentNode.insertBefore(this.wrap,this.img),this.wrap.appendChild(this.img),this.img.classList.add("zoom-img"),this.img.setAttribute("data-action","zoom-out"),this.overlay=document.createElement("div"),this.overlay.classList.add("zoom-overlay"),document.body.appendChild(this.overlay),this.forceRepaint();var e=this.calculateScale(t);this.forceRepaint(),this.animate(e),document.body.classList.add("zoom-overlay-open")},p.prototype.calculateScale=function(t){var e=t.w/this.img.width,n=m()-this.offset,o=u()-this.offset,i=t.w/t.h,r=n/o;return t.w<n&&t.h<o?e:i<r?o/t.h*e:n/t.w*e},p.prototype.animate=function(t){var e=d(this.img),n=window.pageYOffset,o=m()/2,i=n+u()/2,r=e.left+this.img.width/2,s=e.top+this.img.height/2,a=o-r,c=i-s,l="scale("+t+")",f="translate3d("+a+"px, "+c+"px, 0px)";this.img.style.transform=l,this.wrap.style.transform=f},p.prototype.dispose=function(){null!==this.wrap&&null!==this.wrap.parentNode&&(this.img.classList.remove("zoom-img"),this.img.setAttribute("data-action","zoom"),this.wrap.parentNode.insertBefore(this.img,this.wrap),this.wrap.parentNode.removeChild(this.wrap),document.body.removeChild(this.overlay),document.body.classList.remove("zoom-overlay-transitioning"))},p.prototype.close=function(){var t=this;document.body.classList.add("zoom-overlay-transitioning"),this.img.style.transform=this.preservedTransform,0===this.img.style.length&&this.img.removeAttribute("style"),this.wrap.style.transform="none",l(this.img,"transitionend",function(){t.dispose(),document.body.classList.remove("zoom-overlay-open")})};var h=null,v=80,g=-1,y=-1;return function(t){return t.setAttribute("data-action","zoom"),t.addEventListener("click",c),function(){return t.removeEventListener("click",c)}}}()}()})),n='img[data-action="zoom"] {\n cursor: pointer;\n cursor: -webkit-zoom-in;\n cursor: zoom-in;\n}\n.zoom-img,\n.zoom-img-wrap {\n position: relative;\n z-index: 666;\n transition: -webkit-transform 300ms cubic-bezier(.2,0,.2,1);\n transition: transform 300ms cubic-bezier(.2,0,.2,1);\n transition: transform 300ms cubic-bezier(.2,0,.2,1), -webkit-transform 300ms cubic-bezier(.2,0,.2,1);\n}\n.zoom-overlay {\n z-index: 420;\n background: #fff;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n pointer-events: none;\n opacity: 0;\n transition: opacity 300ms;\n}\n.zoom-overlay-open .zoom-overlay {\n opacity: 1;\n}\n.zoom-overlay-open {\n cursor: pointer;\n cursor: -webkit-zoom-out;\n cursor: zoom-out;\n}\n.zoom-overlay-transitioning {\n cursor: default;\n}\n.zoom-overlay-open.zoom-overlay-transitioning .zoom-overlay{\n opacity: 0;\n}\n';$docsify.plugins=[].concat(t,$docsify.plugins)}();
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Generated
+4959
File diff suppressed because it is too large
Load Diff
+16
-7
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "docsify",
|
"name": "docsify",
|
||||||
"version": "3.4.4",
|
"version": "4.2.7",
|
||||||
"description": "A magical documentation generator.",
|
"description": "A magical documentation generator.",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "qingwei-li",
|
"name": "qingwei-li",
|
||||||
@@ -20,28 +20,37 @@
|
|||||||
"themes"
|
"themes"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rm -rf lib themes && node build/build.js && mkdir lib/themes && mkdir themes && node build/build-css.js",
|
"bootstrap": "npm i && lerna bootstrap",
|
||||||
"dev:build": "rm -rf lib themes && mkdir themes && node build/build.js --dev && node build/build-css.js --dev",
|
"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": "node app.js & nodemon -w src -e js,css --exec 'npm run dev:build'",
|
"dev:build": "rm -rf lib themes && mkdir themes && node build/build --dev && node build/build-css --dev",
|
||||||
"test": "eslint src"
|
"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.sh",
|
||||||
|
"pub": "sh build/release.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"marked": "^0.3.6",
|
"marked": "^0.3.6",
|
||||||
"prismjs": "^1.6.0",
|
"prismjs": "^1.6.0",
|
||||||
|
"tinydate": "^1.0.0",
|
||||||
"zoom-image": "^0.1.4"
|
"zoom-image": "^0.1.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"conventional-changelog-cli": "^1.3.2",
|
||||||
"cssnano": "^3.10.0",
|
"cssnano": "^3.10.0",
|
||||||
"eslint": "^3.17.1",
|
"eslint": "^3.18.0",
|
||||||
"eslint-config-vue": "^2.0.2",
|
"eslint-config-vue": "^2.0.2",
|
||||||
"eslint-plugin-vue": "^2.0.1",
|
"eslint-plugin-vue": "^2.0.1",
|
||||||
|
"lerna": "^2.0.0-rc.5",
|
||||||
"nodemon": "^1.11.0",
|
"nodemon": "^1.11.0",
|
||||||
"postcss": "^5.2.16",
|
"postcss": "^5.2.16",
|
||||||
"postcss-salad": "^1.0.8",
|
"postcss-salad": "^1.0.8",
|
||||||
"rollup": "^0.41.5",
|
"rollup": "^0.41.6",
|
||||||
|
"rollup-plugin-async": "^1.2.0",
|
||||||
"rollup-plugin-buble": "^0.15.0",
|
"rollup-plugin-buble": "^0.15.0",
|
||||||
"rollup-plugin-commonjs": "^8.0.2",
|
"rollup-plugin-commonjs": "^8.0.2",
|
||||||
"rollup-plugin-node-resolve": "^2.0.0",
|
"rollup-plugin-node-resolve": "^2.0.0",
|
||||||
|
"rollup-plugin-replace": "^1.1.1",
|
||||||
"rollup-plugin-string": "^2.0.2",
|
"rollup-plugin-string": "^2.0.2",
|
||||||
"rollup-plugin-uglify": "^1.0.1",
|
"rollup-plugin-uglify": "^1.0.1",
|
||||||
"serve-static": "^1.12.1"
|
"serve-static": "^1.12.1"
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
build.js
|
||||||
|
node_modules
|
||||||
|
*.log
|
||||||
|
.git
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# docsify-server-renderer
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn add docsify-server-render
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
var Renderer = require('docsify-server-renderer')
|
||||||
|
var readFileSync = require('fs').readFileSync
|
||||||
|
|
||||||
|
// init
|
||||||
|
var renderer = new Renderer({
|
||||||
|
template: readFileSync('./docs/index.template.html', 'utf-8').,
|
||||||
|
config: {
|
||||||
|
name: 'docsify',
|
||||||
|
repo: 'qingwei-li/docsify'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
renderer.renderToString(url)
|
||||||
|
.then(html => {})
|
||||||
|
.catch(err => {})
|
||||||
|
```
|
||||||
|
|
||||||
|
*index.template.html*
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>docsify</title>
|
||||||
|
<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/buble.css" title="buble" disabled>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!--inject-app-->
|
||||||
|
<!--inject-config-->
|
||||||
|
<script src="//unpkg.com/docsify/lib/docsify.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
import * as tpl from '../../src/core/render/tpl'
|
||||||
|
import fetch from 'node-fetch'
|
||||||
|
import { AbstractHistory } from '../../src/core/router/history/abstract'
|
||||||
|
import { Compiler } from '../../src/core/render/compiler'
|
||||||
|
import { isAbsolutePath } from '../../src/core/router/util'
|
||||||
|
import { readFileSync } from 'fs'
|
||||||
|
import { resolve, basename } from 'path'
|
||||||
|
import resolvePathname from 'resolve-pathname'
|
||||||
|
import debug from 'debug'
|
||||||
|
|
||||||
|
function cwd (...args) {
|
||||||
|
return resolve(process.cwd(), ...args)
|
||||||
|
}
|
||||||
|
|
||||||
|
function mainTpl (config) {
|
||||||
|
let html = `<nav class="app-nav${config.repo ? '' : ' no-badge'}"><!--navbar--></nav>`
|
||||||
|
|
||||||
|
if (config.repo) {
|
||||||
|
html += tpl.corner(config.repo)
|
||||||
|
}
|
||||||
|
if (config.coverpage) {
|
||||||
|
html += tpl.cover()
|
||||||
|
}
|
||||||
|
|
||||||
|
html += tpl.main(config)
|
||||||
|
|
||||||
|
return html
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Renderer {
|
||||||
|
constructor ({
|
||||||
|
template,
|
||||||
|
config,
|
||||||
|
cache
|
||||||
|
}) {
|
||||||
|
this.html = template
|
||||||
|
this.config = config = Object.assign({}, config, {
|
||||||
|
routerMode: 'history'
|
||||||
|
})
|
||||||
|
this.cache = cache
|
||||||
|
|
||||||
|
this.router = new AbstractHistory(config)
|
||||||
|
this.compiler = new Compiler(config, this.router)
|
||||||
|
|
||||||
|
this.router.getCurrentPath = () => this.url
|
||||||
|
this._renderHtml('inject-config', `<script>window.$docsify = ${JSON.stringify(config)}</script>`)
|
||||||
|
this._renderHtml('inject-app', mainTpl(config))
|
||||||
|
|
||||||
|
this.template = this.html
|
||||||
|
}
|
||||||
|
|
||||||
|
_getPath (url) {
|
||||||
|
const file = this.router.getFile(url)
|
||||||
|
|
||||||
|
return isAbsolutePath(file)
|
||||||
|
? file
|
||||||
|
: cwd(`./${file}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
async renderToString (url) {
|
||||||
|
this.url = url = this.router.parse(url).path
|
||||||
|
const { loadSidebar, loadNavbar } = this.config
|
||||||
|
|
||||||
|
const mainFile = this._getPath(url)
|
||||||
|
this._renderHtml('main', await this._render(mainFile))
|
||||||
|
|
||||||
|
if (loadSidebar) {
|
||||||
|
const name = loadSidebar === true ? '_sidebar.md' : loadSidebar
|
||||||
|
const sidebarFile = this._getPath(resolve(url, `./${name}`))
|
||||||
|
this._renderHtml('sidebar', await this._render(sidebarFile, 'sidebar'))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadNavbar) {
|
||||||
|
const name = loadNavbar === true ? '_navbar.md' : loadNavbar
|
||||||
|
const navbarFile = this._getPath(resolve(url, `./${name}`))
|
||||||
|
this._renderHtml('navbar', await this._render(navbarFile, 'navbar'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const html = this.html
|
||||||
|
this.html = this.template
|
||||||
|
|
||||||
|
return html
|
||||||
|
}
|
||||||
|
|
||||||
|
_renderHtml (match, content) {
|
||||||
|
this.html = this.html.replace(new RegExp(`<!--${match}-->`, 'g'), content)
|
||||||
|
|
||||||
|
return this.html
|
||||||
|
}
|
||||||
|
|
||||||
|
async _render (path, type) {
|
||||||
|
let html = await this._loadFile(path)
|
||||||
|
const { subMaxLevel, maxLevel } = this.config
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case 'sidebar':
|
||||||
|
html = this.compiler.sidebar(html, maxLevel) +
|
||||||
|
`<script>window.__SUB_SIDEBAR__ = ${JSON.stringify(
|
||||||
|
this.compiler.subSidebar(subMaxLevel)
|
||||||
|
)}</script>`
|
||||||
|
break
|
||||||
|
case 'cover':
|
||||||
|
html = this.compiler.cover(html)
|
||||||
|
break
|
||||||
|
case 'navbar':
|
||||||
|
case 'article':
|
||||||
|
default:
|
||||||
|
html = this.compiler.compile(html)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return html
|
||||||
|
}
|
||||||
|
|
||||||
|
async _loadFile (filePath) {
|
||||||
|
debug('docsify')(`load > ${filePath}`)
|
||||||
|
let content
|
||||||
|
try {
|
||||||
|
if (isAbsolutePath(filePath)) {
|
||||||
|
const res = await fetch(filePath)
|
||||||
|
if (!res.ok) throw Error()
|
||||||
|
content = await res.text()
|
||||||
|
this.lock = 0
|
||||||
|
} else {
|
||||||
|
content = await readFileSync(filePath, 'utf8')
|
||||||
|
this.lock = 0
|
||||||
|
}
|
||||||
|
return content
|
||||||
|
} catch (e) {
|
||||||
|
this.lock = this.lock || 0
|
||||||
|
if (++this.lock > 10) {
|
||||||
|
this.lock = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileName = basename(filePath)
|
||||||
|
|
||||||
|
return await this._loadFile(resolvePathname(`../${fileName}`, filePath))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Renderer.version = '__VERSION__'
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"dependencies": {
|
||||||
|
"debug": {
|
||||||
|
"version": "2.6.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
|
||||||
|
"integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw="
|
||||||
|
},
|
||||||
|
"encoding": {
|
||||||
|
"version": "0.1.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
|
||||||
|
"integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s="
|
||||||
|
},
|
||||||
|
"iconv-lite": {
|
||||||
|
"version": "0.4.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz",
|
||||||
|
"integrity": "sha512-sr1ZQph3UwHTR0XftSbK85OvBbxe/abLGzEnPENCQwmHf7sck8Oyu4ob3LgBxWWxRoM+QszeUyl7jbqapu2TqA=="
|
||||||
|
},
|
||||||
|
"is-stream": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
|
||||||
|
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||||
|
},
|
||||||
|
"node-fetch": {
|
||||||
|
"version": "1.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.1.tgz",
|
||||||
|
"integrity": "sha512-j8XsFGCLw79vWXkZtMSmmLaOk9z5SQ9bV/tkbZVCqvgwzrjAGq66igobLofHtF63NvMTp2WjytpsNTGKa+XRIQ=="
|
||||||
|
},
|
||||||
|
"resolve-pathname": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-2.1.0.tgz",
|
||||||
|
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"version": "4.2.7"
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "docsify-server-renderer",
|
||||||
|
"version": "4.2.7",
|
||||||
|
"description": "docsify server renderer",
|
||||||
|
"author": {
|
||||||
|
"name": "qingwei-li",
|
||||||
|
"email": "cinwell.li@gmail.com",
|
||||||
|
"url": "https://github.com/QingWei-Li"
|
||||||
|
},
|
||||||
|
"homepage": "https://docsify.js.org",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "QingWei-Li/docsify",
|
||||||
|
"main": "build.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo 'hello'"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"debug": "^2.6.8",
|
||||||
|
"node-fetch": "^1.7.0",
|
||||||
|
"resolve-pathname": "^2.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-1
@@ -17,7 +17,12 @@ const config = merge({
|
|||||||
autoHeader: false,
|
autoHeader: false,
|
||||||
executeScript: null,
|
executeScript: null,
|
||||||
noEmoji: false,
|
noEmoji: false,
|
||||||
ga: ''
|
ga: '',
|
||||||
|
mergeNavbar: false,
|
||||||
|
formatUpdated: '',
|
||||||
|
externalLinkTarget: '_blank',
|
||||||
|
routerModel: 'hash',
|
||||||
|
noCompileLinks: []
|
||||||
}, window.$docsify)
|
}, window.$docsify)
|
||||||
|
|
||||||
const script = document.currentScript ||
|
const script = document.currentScript ||
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import { scrollIntoView } from './scroll'
|
|||||||
export function eventMixin (proto) {
|
export function eventMixin (proto) {
|
||||||
proto.$resetEvents = function () {
|
proto.$resetEvents = function () {
|
||||||
scrollIntoView(this.route.query.id)
|
scrollIntoView(this.route.query.id)
|
||||||
sidebar.getAndActive('nav')
|
sidebar.getAndActive(this.router, 'nav')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initEvent (vm) {
|
export function initEvent (vm) {
|
||||||
// Bind toggle button
|
// Bind toggle button
|
||||||
sidebar.btn('button.sidebar-toggle')
|
sidebar.btn('button.sidebar-toggle', vm.router)
|
||||||
// Bind sticky effect
|
// Bind sticky effect
|
||||||
if (vm.config.coverpage) {
|
if (vm.config.coverpage) {
|
||||||
!isMobile && on('scroll', sidebar.sticky)
|
!isMobile && on('scroll', sidebar.sticky)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { isMobile } from '../util/env'
|
import { isMobile } from '../util/env'
|
||||||
import * as dom from '../util/dom'
|
import * as dom from '../util/dom'
|
||||||
import { parse } from '../route/hash'
|
|
||||||
|
|
||||||
const nav = {}
|
const nav = {}
|
||||||
let hoverOver = false
|
let hoverOver = false
|
||||||
@@ -53,7 +52,7 @@ function highlight () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function scrollActiveSidebar () {
|
export function scrollActiveSidebar (router) {
|
||||||
if (isMobile) return
|
if (isMobile) return
|
||||||
|
|
||||||
const sidebar = dom.getNode('.sidebar')
|
const sidebar = dom.getNode('.sidebar')
|
||||||
@@ -66,7 +65,7 @@ export function scrollActiveSidebar () {
|
|||||||
let href = a.getAttribute('href')
|
let href = a.getAttribute('href')
|
||||||
|
|
||||||
if (href !== '/') {
|
if (href !== '/') {
|
||||||
href = parse(href).query.id
|
href = router.parse(href).query.id
|
||||||
}
|
}
|
||||||
|
|
||||||
nav[decodeURIComponent(href)] = li
|
nav[decodeURIComponent(href)] = li
|
||||||
|
|||||||
+15
-10
@@ -1,23 +1,27 @@
|
|||||||
import { isMobile } from '../util/env'
|
import { isMobile } from '../util/env'
|
||||||
import * as dom from '../util/dom'
|
import * as dom from '../util/dom'
|
||||||
import { getHash } from '../route/hash'
|
|
||||||
|
|
||||||
const title = dom.$.title
|
const title = dom.$.title
|
||||||
/**
|
/**
|
||||||
* Toggle button
|
* Toggle button
|
||||||
*/
|
*/
|
||||||
export function btn (el) {
|
export function btn (el, router) {
|
||||||
const toggle = () => dom.body.classList.toggle('close')
|
const toggle = _ => dom.body.classList.toggle('close')
|
||||||
|
|
||||||
el = dom.getNode(el)
|
el = dom.getNode(el)
|
||||||
dom.on(el, 'click', toggle)
|
dom.on(el, 'click', e => {
|
||||||
|
e.stopPropagation()
|
||||||
|
toggle()
|
||||||
|
})
|
||||||
|
|
||||||
const sidebar = dom.getNode('.sidebar')
|
const sidebar = dom.getNode('.sidebar')
|
||||||
|
|
||||||
dom.on(sidebar, 'click', () => {
|
isMobile && dom.on(dom.body, 'click', _ =>
|
||||||
isMobile && toggle()
|
dom.body.classList.contains('close') && toggle()
|
||||||
setTimeout(() => getAndActive(sidebar, true, true), 0)
|
)
|
||||||
})
|
dom.on(sidebar, 'click', _ =>
|
||||||
|
setTimeout((_ => getAndActive(router, sidebar, true, true), 0))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sticky () {
|
export function sticky () {
|
||||||
@@ -34,16 +38,17 @@ export function sticky () {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get and active link
|
* Get and active link
|
||||||
|
* @param {object} router
|
||||||
* @param {string|element} el
|
* @param {string|element} el
|
||||||
* @param {Boolean} isParent acitve parent
|
* @param {Boolean} isParent acitve parent
|
||||||
* @param {Boolean} autoTitle auto set title
|
* @param {Boolean} autoTitle auto set title
|
||||||
* @return {element}
|
* @return {element}
|
||||||
*/
|
*/
|
||||||
export function getAndActive (el, isParent, autoTitle) {
|
export function getAndActive (router, el, isParent, autoTitle) {
|
||||||
el = dom.getNode(el)
|
el = dom.getNode(el)
|
||||||
|
|
||||||
const links = dom.findAll(el, 'a')
|
const links = dom.findAll(el, 'a')
|
||||||
const hash = '#' + getHash()
|
const hash = router.toURL(router.getCurrentPath())
|
||||||
let target
|
let target
|
||||||
|
|
||||||
links
|
links
|
||||||
|
|||||||
+11
-4
@@ -14,9 +14,10 @@ export function get (url, hasBar = false) {
|
|||||||
const on = function () {
|
const on = function () {
|
||||||
xhr.addEventListener.apply(xhr, arguments)
|
xhr.addEventListener.apply(xhr, arguments)
|
||||||
}
|
}
|
||||||
|
const cached = cache[url]
|
||||||
|
|
||||||
if (cache[url]) {
|
if (cached) {
|
||||||
return { then: cb => cb(cache[url]), abort: noop }
|
return { then: cb => cb(cached.content, cached.opt), abort: noop }
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.open('GET', url)
|
xhr.open('GET', url)
|
||||||
@@ -41,8 +42,14 @@ export function get (url, hasBar = false) {
|
|||||||
if (target.status >= 400) {
|
if (target.status >= 400) {
|
||||||
error(target)
|
error(target)
|
||||||
} else {
|
} else {
|
||||||
cache[url] = target.response
|
const result = cache[url] = {
|
||||||
success(target.response)
|
content: target.response,
|
||||||
|
opt: {
|
||||||
|
updatedAt: xhr.getResponseHeader('last-modified')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
success(result.content, result.opt)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
+32
-9
@@ -1,7 +1,8 @@
|
|||||||
import { get } from './ajax'
|
import { get } from './ajax'
|
||||||
import { callHook } from '../init/lifecycle'
|
import { callHook } from '../init/lifecycle'
|
||||||
import { getParentPath } from '../route/util'
|
import { getParentPath } from '../router/util'
|
||||||
import { noop } from '../util/core'
|
import { noop } from '../util/core'
|
||||||
|
import { getAndActive } from '../event/sidebar'
|
||||||
|
|
||||||
function loadNested (path, file, next, vm, first) {
|
function loadNested (path, file, next, vm, first) {
|
||||||
path = first ? path : path.replace(/\/$/, '')
|
path = first ? path : path.replace(/\/$/, '')
|
||||||
@@ -9,7 +10,7 @@ function loadNested (path, file, next, vm, first) {
|
|||||||
|
|
||||||
if (!path) return
|
if (!path) return
|
||||||
|
|
||||||
get(vm.$getFile(path + file))
|
get(vm.router.getFile(path + file))
|
||||||
.then(next, _ => loadNested(path, file, next, vm))
|
.then(next, _ => loadNested(path, file, next, vm))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,22 +23,29 @@ export function fetchMixin (proto) {
|
|||||||
// Abort last request
|
// Abort last request
|
||||||
last && last.abort && last.abort()
|
last && last.abort && last.abort()
|
||||||
|
|
||||||
last = get(this.$getFile(path), true)
|
last = get(this.router.getFile(path), true)
|
||||||
|
|
||||||
// Current page is html
|
// Current page is html
|
||||||
this.isHTML = /\.html$/g.test(path)
|
this.isHTML = /\.html$/g.test(path)
|
||||||
|
|
||||||
// Load main content
|
const loadSideAndNav = () => {
|
||||||
last.then(text => {
|
|
||||||
this._renderMain(text)
|
|
||||||
if (!loadSidebar) return cb()
|
if (!loadSidebar) return cb()
|
||||||
|
|
||||||
const fn = result => { this._renderSidebar(result); cb() }
|
const fn = result => { this._renderSidebar(result); cb() }
|
||||||
|
|
||||||
// Load sidebar
|
// Load sidebar
|
||||||
loadNested(path, loadSidebar, fn, this, true)
|
loadNested(path, loadSidebar, fn, this, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load main content
|
||||||
|
last.then((text, opt) => {
|
||||||
|
this._renderMain(text, opt)
|
||||||
|
loadSideAndNav()
|
||||||
},
|
},
|
||||||
_ => this._renderMain(null))
|
_ => {
|
||||||
|
this._renderMain(null)
|
||||||
|
loadSideAndNav()
|
||||||
|
})
|
||||||
|
|
||||||
// Load nav
|
// Load nav
|
||||||
loadNavbar &&
|
loadNavbar &&
|
||||||
@@ -47,7 +55,7 @@ export function fetchMixin (proto) {
|
|||||||
proto._fetchCover = function () {
|
proto._fetchCover = function () {
|
||||||
const { coverpage } = this.config
|
const { coverpage } = this.config
|
||||||
const root = getParentPath(this.route.path)
|
const root = getParentPath(this.route.path)
|
||||||
const path = this.$getFile(root + coverpage)
|
const path = this.router.getFile(root + coverpage)
|
||||||
|
|
||||||
if (this.route.path !== '/' || !coverpage) {
|
if (this.route.path !== '/' || !coverpage) {
|
||||||
this._renderCover()
|
this._renderCover()
|
||||||
@@ -70,5 +78,20 @@ export function fetchMixin (proto) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function initFetch (vm) {
|
export function initFetch (vm) {
|
||||||
vm.$fetch(_ => callHook(vm, 'ready'))
|
const { loadSidebar } = vm.config
|
||||||
|
|
||||||
|
// server-client renderer
|
||||||
|
if (vm.rendered) {
|
||||||
|
const activeEl = getAndActive(vm.router, '.sidebar-nav', true, true)
|
||||||
|
if (loadSidebar && activeEl) {
|
||||||
|
activeEl.parentNode.innerHTML += window.__SUB_SIDEBAR__
|
||||||
|
}
|
||||||
|
vm._bindEventOnRendered(activeEl)
|
||||||
|
vm._fetchCover()
|
||||||
|
vm.$resetEvents()
|
||||||
|
callHook(vm, 'doneEach')
|
||||||
|
callHook(vm, 'ready')
|
||||||
|
} else {
|
||||||
|
vm.$fetch(_ => callHook(vm, 'ready'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import * as util from './util'
|
import * as util from './util'
|
||||||
import * as dom from './util/dom'
|
import * as dom from './util/dom'
|
||||||
import * as render from './render/compiler'
|
import { Compiler } from './render/compiler'
|
||||||
import * as route from './route/hash'
|
|
||||||
import { slugify } from './render/slugify'
|
import { slugify } from './render/slugify'
|
||||||
import { get } from './fetch/ajax'
|
import { get } from './fetch/ajax'
|
||||||
import marked from 'marked'
|
import marked from 'marked'
|
||||||
import prism from 'prismjs'
|
import prism from 'prismjs'
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
window.Docsify = { util, dom, render, route, get, slugify }
|
window.Docsify = { util, dom, get, slugify }
|
||||||
|
window.DocsifyCompiler = Compiler
|
||||||
window.marked = marked
|
window.marked = marked
|
||||||
window.Prism = prism
|
window.Prism = prism
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -1,5 +1,5 @@
|
|||||||
import { initMixin } from './init'
|
import { initMixin } from './init'
|
||||||
import { routeMixin } from './route'
|
import { routerMixin } from './router'
|
||||||
import { renderMixin } from './render'
|
import { renderMixin } from './render'
|
||||||
import { fetchMixin } from './fetch'
|
import { fetchMixin } from './fetch'
|
||||||
import { eventMixin } from './event'
|
import { eventMixin } from './event'
|
||||||
@@ -12,7 +12,7 @@ function Docsify () {
|
|||||||
const proto = Docsify.prototype
|
const proto = Docsify.prototype
|
||||||
|
|
||||||
initMixin(proto)
|
initMixin(proto)
|
||||||
routeMixin(proto)
|
routerMixin(proto)
|
||||||
renderMixin(proto)
|
renderMixin(proto)
|
||||||
fetchMixin(proto)
|
fetchMixin(proto)
|
||||||
eventMixin(proto)
|
eventMixin(proto)
|
||||||
@@ -22,6 +22,11 @@ eventMixin(proto)
|
|||||||
*/
|
*/
|
||||||
initGlobalAPI()
|
initGlobalAPI()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version
|
||||||
|
*/
|
||||||
|
Docsify.version = '__VERSION__'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run Docsify
|
* Run Docsify
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import config from '../config'
|
import config from '../config'
|
||||||
import { initLifecycle, callHook } from './lifecycle'
|
import { initLifecycle, callHook } from './lifecycle'
|
||||||
import { initRender } from '../render'
|
import { initRender } from '../render'
|
||||||
import { initRoute } from '../route'
|
import { initRouter } from '../router'
|
||||||
import { initEvent } from '../event'
|
import { initEvent } from '../event'
|
||||||
import { initFetch } from '../fetch'
|
import { initFetch } from '../fetch'
|
||||||
import { isFn } from '../util/core'
|
import { isFn } from '../util/core'
|
||||||
@@ -14,9 +14,9 @@ export function initMixin (proto) {
|
|||||||
initLifecycle(vm) // Init hooks
|
initLifecycle(vm) // Init hooks
|
||||||
initPlugin(vm) // Install plugins
|
initPlugin(vm) // Install plugins
|
||||||
callHook(vm, 'init')
|
callHook(vm, 'init')
|
||||||
|
initRouter(vm) // Add router
|
||||||
initRender(vm) // Render base DOM
|
initRender(vm) // Render base DOM
|
||||||
initEvent(vm) // Bind events
|
initEvent(vm) // Bind events
|
||||||
initRoute(vm) // Add hashchange eventListener
|
|
||||||
initFetch(vm) // Fetch data
|
initFetch(vm) // Fetch data
|
||||||
callHook(vm, 'mounted')
|
callHook(vm, 'mounted')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,23 +19,22 @@ export function initLifecycle (vm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function callHook (vm, hook, data, next = noop) {
|
export function callHook (vm, hook, data, next = noop) {
|
||||||
let newData = data
|
|
||||||
const queue = vm._hooks[hook]
|
const queue = vm._hooks[hook]
|
||||||
|
|
||||||
const step = function (index) {
|
const step = function (index) {
|
||||||
const hook = queue[index]
|
const hook = queue[index]
|
||||||
if (index >= queue.length) {
|
if (index >= queue.length) {
|
||||||
next(newData)
|
next(data)
|
||||||
} else {
|
} else {
|
||||||
if (typeof hook === 'function') {
|
if (typeof hook === 'function') {
|
||||||
if (hook.length === 2) {
|
if (hook.length === 2) {
|
||||||
hook(data, result => {
|
hook(data, result => {
|
||||||
newData = result
|
data = result
|
||||||
step(index + 1)
|
step(index + 1)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const result = hook(data)
|
const result = hook(data)
|
||||||
newData = result !== undefined ? result : newData
|
data = result !== undefined ? result : data
|
||||||
step(index + 1)
|
step(index + 1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+153
-118
@@ -4,155 +4,190 @@ import { helper as helperTpl, tree as treeTpl } from './tpl'
|
|||||||
import { genTree } from './gen-tree'
|
import { genTree } from './gen-tree'
|
||||||
import { slugify } from './slugify'
|
import { slugify } from './slugify'
|
||||||
import { emojify } from './emojify'
|
import { emojify } from './emojify'
|
||||||
import { toURL, parse } from '../route/hash'
|
import { isAbsolutePath, getPath } from '../router/util'
|
||||||
import { getBasePath, isAbsolutePath, getPath } from '../route/util'
|
|
||||||
import { isFn, merge, cached } from '../util/core'
|
import { isFn, merge, cached } from '../util/core'
|
||||||
|
|
||||||
let markdownCompiler = marked
|
const cachedLinks = {}
|
||||||
let contentBase = ''
|
|
||||||
let currentPath = ''
|
|
||||||
let renderer = new marked.Renderer()
|
|
||||||
const cacheTree = {}
|
|
||||||
let toc = []
|
|
||||||
|
|
||||||
/**
|
export class Compiler {
|
||||||
* Compile markdown content
|
constructor (config, router) {
|
||||||
*/
|
this.config = config
|
||||||
export const markdown = cached(text => {
|
this.router = router
|
||||||
let html = ''
|
this.cacheTree = {}
|
||||||
|
this.toc = []
|
||||||
|
this.linkTarget = config.externalLinkTarget || '_blank'
|
||||||
|
this.contentBase = router.getBasePath()
|
||||||
|
|
||||||
if (!text) return text
|
const renderer = this._initRenderer()
|
||||||
|
let compile
|
||||||
|
const mdConf = config.markdown || {}
|
||||||
|
|
||||||
html = markdownCompiler(text)
|
if (isFn(mdConf)) {
|
||||||
html = emojify(html)
|
compile = mdConf(marked, renderer)
|
||||||
slugify.clear()
|
} else {
|
||||||
|
marked.setOptions(merge(mdConf, {
|
||||||
|
renderer: merge(renderer, mdConf.renderer)
|
||||||
|
}))
|
||||||
|
compile = marked
|
||||||
|
}
|
||||||
|
|
||||||
return html
|
this.compile = cached(text => {
|
||||||
})
|
let html = ''
|
||||||
|
|
||||||
markdown.renderer = renderer
|
if (!text) return text
|
||||||
|
|
||||||
markdown.init = function (config = {}, base = window.location.pathname) {
|
html = compile(text)
|
||||||
contentBase = getBasePath(base)
|
html = config.noEmoji ? html : emojify(html)
|
||||||
|
slugify.clear()
|
||||||
|
|
||||||
if (isFn(config)) {
|
return html
|
||||||
markdownCompiler = config(marked, renderer)
|
})
|
||||||
} else {
|
|
||||||
renderer = merge(renderer, config.renderer)
|
|
||||||
marked.setOptions(merge(config, { renderer }))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
markdown.update = function () {
|
|
||||||
currentPath = parse().path
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* render anchor tag
|
|
||||||
* @link https://github.com/chjj/marked#overriding-renderer-methods
|
|
||||||
*/
|
|
||||||
renderer.heading = function (text, level) {
|
|
||||||
const nextToc = { level, title: text }
|
|
||||||
|
|
||||||
if (/{docsify-ignore}/g.test(text)) {
|
|
||||||
text = text.replace('{docsify-ignore}', '')
|
|
||||||
nextToc.title = text
|
|
||||||
nextToc.ignoreSubHeading = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/{docsify-ignore-all}/g.test(text)) {
|
matchNotCompileLink (link) {
|
||||||
text = text.replace('{docsify-ignore-all}', '')
|
const links = this.config.noCompileLinks
|
||||||
nextToc.title = text
|
|
||||||
nextToc.ignoreAllSubs = true
|
for (var i = 0; i < links.length; i++) {
|
||||||
|
const n = links[i]
|
||||||
|
const re = cachedLinks[n] || (cachedLinks[n] = new RegExp(`^${n}$`))
|
||||||
|
|
||||||
|
if (re.test(link)) {
|
||||||
|
return link
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const slug = slugify(text)
|
_initRenderer () {
|
||||||
const url = toURL(currentPath, { id: slug })
|
const renderer = new marked.Renderer()
|
||||||
nextToc.slug = url
|
const { linkTarget, router, contentBase } = this
|
||||||
toc.push(nextToc)
|
const _self = this
|
||||||
|
/**
|
||||||
|
* render anchor tag
|
||||||
|
* @link https://github.com/chjj/marked#overriding-renderer-methods
|
||||||
|
*/
|
||||||
|
renderer.heading = function (text, level) {
|
||||||
|
const nextToc = { level, title: text }
|
||||||
|
|
||||||
return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${text}</span></a></h${level}>`
|
if (/{docsify-ignore}/g.test(text)) {
|
||||||
}
|
text = text.replace('{docsify-ignore}', '')
|
||||||
// highlight code
|
nextToc.title = text
|
||||||
renderer.code = function (code, lang = '') {
|
nextToc.ignoreSubHeading = true
|
||||||
const hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
|
}
|
||||||
|
|
||||||
return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
|
if (/{docsify-ignore-all}/g.test(text)) {
|
||||||
}
|
text = text.replace('{docsify-ignore-all}', '')
|
||||||
renderer.link = function (href, title, text) {
|
nextToc.title = text
|
||||||
let blank = ''
|
nextToc.ignoreAllSubs = true
|
||||||
if (!/:|(\/{2})/.test(href)) {
|
}
|
||||||
href = toURL(href)
|
|
||||||
} else {
|
|
||||||
blank = ' target="_blank"'
|
|
||||||
}
|
|
||||||
if (title) {
|
|
||||||
title = ` title="${title}"`
|
|
||||||
}
|
|
||||||
return `<a href="${href}"${title || ''}${blank}>${text}</a>`
|
|
||||||
}
|
|
||||||
renderer.paragraph = function (text) {
|
|
||||||
if (/^!>/.test(text)) {
|
|
||||||
return helperTpl('tip', text)
|
|
||||||
} else if (/^\?>/.test(text)) {
|
|
||||||
return helperTpl('warn', text)
|
|
||||||
}
|
|
||||||
return `<p>${text}</p>`
|
|
||||||
}
|
|
||||||
renderer.image = function (href, title, text) {
|
|
||||||
let url = href
|
|
||||||
const titleHTML = title ? ` title="${title}"` : ''
|
|
||||||
|
|
||||||
if (!isAbsolutePath(href)) {
|
const slug = slugify(text)
|
||||||
url = getPath(contentBase, href)
|
const url = router.toURL(router.getCurrentPath(), { id: slug })
|
||||||
|
nextToc.slug = url
|
||||||
|
_self.toc.push(nextToc)
|
||||||
|
|
||||||
|
return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${text}</span></a></h${level}>`
|
||||||
|
}
|
||||||
|
// highlight code
|
||||||
|
renderer.code = function (code, lang = '') {
|
||||||
|
const hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
|
||||||
|
|
||||||
|
return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
|
||||||
|
}
|
||||||
|
renderer.link = function (href, title, text) {
|
||||||
|
let blank = ''
|
||||||
|
|
||||||
|
if (!/:|(\/{2})/.test(href) &&
|
||||||
|
!_self.matchNotCompileLink(href) &&
|
||||||
|
!/(\s?:ignore)(\s\S+)?$/.test(title)) {
|
||||||
|
href = router.toURL(href, null, router.getCurrentPath())
|
||||||
|
} else {
|
||||||
|
blank = ` target="${linkTarget}"`
|
||||||
|
title = title && title.replace(/:ignore/g, '').trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title) {
|
||||||
|
title = ` title="${title}"`
|
||||||
|
}
|
||||||
|
return `<a href="${href}"${title || ''}${blank}>${text}</a>`
|
||||||
|
}
|
||||||
|
renderer.paragraph = function (text) {
|
||||||
|
if (/^!>/.test(text)) {
|
||||||
|
return helperTpl('tip', text)
|
||||||
|
} else if (/^\?>/.test(text)) {
|
||||||
|
return helperTpl('warn', text)
|
||||||
|
}
|
||||||
|
return `<p>${text}</p>`
|
||||||
|
}
|
||||||
|
renderer.image = function (href, title, text) {
|
||||||
|
let url = href
|
||||||
|
const titleHTML = title ? ` title="${title}"` : ''
|
||||||
|
|
||||||
|
if (!isAbsolutePath(href)) {
|
||||||
|
url = getPath(contentBase, href)
|
||||||
|
}
|
||||||
|
|
||||||
|
return `<img src="${url}" data-origin="${href}" alt="${text}"${titleHTML}>`
|
||||||
|
}
|
||||||
|
|
||||||
|
return renderer
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<img src="${url}" data-origin="${href}" alt="${text}"${titleHTML}>`
|
/**
|
||||||
}
|
* Compile sidebar
|
||||||
|
*/
|
||||||
|
sidebar (text, level) {
|
||||||
|
const currentPath = this.router.getCurrentPath()
|
||||||
|
let html = ''
|
||||||
|
|
||||||
/**
|
if (text) {
|
||||||
* Compile sidebar
|
html = this.compile(text)
|
||||||
*/
|
html = html && html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0]
|
||||||
export function sidebar (text, level) {
|
} else {
|
||||||
let html = ''
|
const tree = this.cacheTree[currentPath] || genTree(this.toc, level)
|
||||||
|
html = treeTpl(tree, '<ul>')
|
||||||
|
this.cacheTree[currentPath] = tree
|
||||||
|
}
|
||||||
|
|
||||||
if (text) {
|
return html
|
||||||
html = markdown(text)
|
|
||||||
html = html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0]
|
|
||||||
} else {
|
|
||||||
const tree = cacheTree[currentPath] || genTree(toc, level)
|
|
||||||
html = treeTpl(tree, '<ul>')
|
|
||||||
cacheTree[currentPath] = tree
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return html
|
/**
|
||||||
}
|
* Compile sub sidebar
|
||||||
|
*/
|
||||||
|
subSidebar (level) {
|
||||||
|
if (!level) {
|
||||||
|
this.toc = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const currentPath = this.router.getCurrentPath()
|
||||||
|
const { cacheTree, toc } = this
|
||||||
|
|
||||||
/**
|
toc[0] && toc[0].ignoreAllSubs && (this.toc = [])
|
||||||
* Compile sub sidebar
|
|
||||||
*/
|
|
||||||
export function subSidebar (el, level) {
|
|
||||||
if (el) {
|
|
||||||
toc[0] && toc[0].ignoreAllSubs && (toc = [])
|
|
||||||
toc[0] && toc[0].level === 1 && toc.shift()
|
toc[0] && toc[0].level === 1 && toc.shift()
|
||||||
toc.forEach((node, i) => {
|
toc.forEach((node, i) => {
|
||||||
node.ignoreSubHeading && toc.splice(i, 1)
|
node.ignoreSubHeading && toc.splice(i, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
const tree = cacheTree[currentPath] || genTree(toc, level)
|
const tree = cacheTree[currentPath] || genTree(toc, level)
|
||||||
el.parentNode.innerHTML += treeTpl(tree, '<ul class="app-sub-sidebar">')
|
|
||||||
cacheTree[currentPath] = tree
|
cacheTree[currentPath] = tree
|
||||||
|
this.toc = []
|
||||||
|
return treeTpl(tree, '<ul class="app-sub-sidebar">')
|
||||||
}
|
}
|
||||||
toc = []
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
article (text) {
|
||||||
* Compile cover page
|
return this.compile(text)
|
||||||
*/
|
}
|
||||||
export function cover (text) {
|
|
||||||
const cacheToc = toc.slice()
|
|
||||||
const html = markdown(text)
|
|
||||||
|
|
||||||
toc = cacheToc.slice()
|
/**
|
||||||
|
* Compile cover page
|
||||||
|
*/
|
||||||
|
cover (text) {
|
||||||
|
const cacheToc = this.toc.slice()
|
||||||
|
const html = this.compile(text)
|
||||||
|
|
||||||
return html
|
this.toc = cacheToc.slice()
|
||||||
|
|
||||||
|
return html
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
import { inBrowser } from '../util/env'
|
||||||
|
|
||||||
function replace (m, $1) {
|
function replace (m, $1) {
|
||||||
return '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' + $1 + '.png" alt="' + $1 + '" />'
|
return '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/' + $1 + '.png" alt="' + $1 + '" />'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function emojify (text) {
|
export function emojify (text) {
|
||||||
return $docsify.noEmoji ? text : text
|
return text
|
||||||
.replace(/<(pre|template|code)[^>]*?>[\s\S]+?<\/(pre|template|code)>/g, m => m.replace(/:/g, '__colon__'))
|
.replace(/<(pre|template|code)[^>]*?>[\s\S]+?<\/(pre|template|code)>/g, m => m.replace(/:/g, '__colon__'))
|
||||||
.replace(/:(\w+?):/ig, window.emojify || replace)
|
.replace(/:(\w+?):/ig, (inBrowser && window.emojify) || replace)
|
||||||
.replace(/__colon__/g, ':')
|
.replace(/__colon__/g, ':')
|
||||||
}
|
}
|
||||||
|
|||||||
+81
-44
@@ -1,12 +1,14 @@
|
|||||||
import * as dom from '../util/dom'
|
import * as dom from '../util/dom'
|
||||||
import { getAndActive, sticky } from '../event/sidebar'
|
|
||||||
import { scrollActiveSidebar, scroll2Top } from '../event/scroll'
|
|
||||||
import cssVars from '../util/polyfill/css-vars'
|
|
||||||
import * as tpl from './tpl'
|
import * as tpl from './tpl'
|
||||||
import { markdown, sidebar, subSidebar, cover } from './compiler'
|
import cssVars from '../util/polyfill/css-vars'
|
||||||
|
import tinydate from 'tinydate'
|
||||||
import { callHook } from '../init/lifecycle'
|
import { callHook } from '../init/lifecycle'
|
||||||
import { getBasePath, getPath, isAbsolutePath } from '../route/util'
|
import { Compiler } from './compiler'
|
||||||
|
import { getAndActive, sticky } from '../event/sidebar'
|
||||||
|
import { getPath, isAbsolutePath } from '../router/util'
|
||||||
|
import { isMobile } from '../util/env'
|
||||||
import { isPrimitive } from '../util/core'
|
import { isPrimitive } from '../util/core'
|
||||||
|
import { scrollActiveSidebar, scroll2Top } from '../event/scroll'
|
||||||
|
|
||||||
function executeScript () {
|
function executeScript () {
|
||||||
const script = dom.findAll('.markdown-section>script')
|
const script = dom.findAll('.markdown-section>script')
|
||||||
@@ -20,6 +22,16 @@ function executeScript () {
|
|||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatUpdated (html, updated, fn) {
|
||||||
|
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) {
|
function renderMain (html) {
|
||||||
if (!html) {
|
if (!html) {
|
||||||
// TODO: Custom 404 page
|
// TODO: Custom 404 page
|
||||||
@@ -42,10 +54,6 @@ function renderMain (html) {
|
|||||||
} else {
|
} else {
|
||||||
this.config.executeScript && executeScript()
|
this.config.executeScript && executeScript()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.config.auto2top) {
|
|
||||||
scroll2Top(this.config.auto2top)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderNameLink (vm) {
|
function renderNameLink (vm) {
|
||||||
@@ -58,7 +66,7 @@ function renderNameLink (vm) {
|
|||||||
if (isPrimitive(vm.config.nameLink)) {
|
if (isPrimitive(vm.config.nameLink)) {
|
||||||
el.setAttribute('href', nameLink)
|
el.setAttribute('href', nameLink)
|
||||||
} else if (typeof nameLink === 'object') {
|
} else if (typeof nameLink === 'object') {
|
||||||
const match = Object.keys(nameLink).find(key => path.indexOf(key) > -1)
|
const match = Object.keys(nameLink).filter(key => path.indexOf(key) > -1)[0]
|
||||||
|
|
||||||
el.setAttribute('href', nameLink[match])
|
el.setAttribute('href', nameLink[match])
|
||||||
}
|
}
|
||||||
@@ -71,34 +79,54 @@ export function renderMixin (proto) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proto._renderSidebar = function (text) {
|
proto._renderSidebar = function (text) {
|
||||||
const { maxLevel, subMaxLevel, autoHeader, loadSidebar } = this.config
|
const { maxLevel, subMaxLevel, loadSidebar } = this.config
|
||||||
|
|
||||||
this._renderTo('.sidebar-nav', sidebar(text, maxLevel))
|
this._renderTo('.sidebar-nav', this.compiler.sidebar(text, maxLevel))
|
||||||
const active = getAndActive('.sidebar-nav', true, true)
|
const activeEl = getAndActive(this.router, '.sidebar-nav', true, true)
|
||||||
subSidebar(loadSidebar ? active : '', subMaxLevel)
|
if (loadSidebar && activeEl) {
|
||||||
|
activeEl.parentNode.innerHTML += (this.compiler.subSidebar(subMaxLevel) || '')
|
||||||
|
} else {
|
||||||
|
// reset toc
|
||||||
|
this.compiler.subSidebar()
|
||||||
|
}
|
||||||
// bind event
|
// bind event
|
||||||
this.activeLink = active
|
this._bindEventOnRendered(activeEl)
|
||||||
scrollActiveSidebar()
|
}
|
||||||
|
|
||||||
if (autoHeader && active) {
|
proto._bindEventOnRendered = function (activeEl) {
|
||||||
|
const { autoHeader, auto2top } = this.config
|
||||||
|
|
||||||
|
scrollActiveSidebar(this.router)
|
||||||
|
|
||||||
|
if (autoHeader && activeEl) {
|
||||||
const main = dom.getNode('#main')
|
const main = dom.getNode('#main')
|
||||||
const firstNode = main.children[0]
|
const firstNode = main.children[0]
|
||||||
if (firstNode && firstNode.tagName !== 'H1') {
|
if (firstNode && firstNode.tagName !== 'H1') {
|
||||||
const h1 = dom.create('h1')
|
const h1 = dom.create('h1')
|
||||||
h1.innerText = active.innerText
|
h1.innerText = activeEl.innerText
|
||||||
dom.before(main, h1)
|
dom.before(main, h1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto2top && scroll2Top(auto2top)
|
||||||
}
|
}
|
||||||
|
|
||||||
proto._renderNav = function (text) {
|
proto._renderNav = function (text) {
|
||||||
text && this._renderTo('nav', markdown(text))
|
text && this._renderTo('nav', this.compiler.compile(text))
|
||||||
getAndActive('nav')
|
getAndActive(this.router, 'nav')
|
||||||
}
|
}
|
||||||
|
|
||||||
proto._renderMain = function (text) {
|
proto._renderMain = function (text, opt = {}) {
|
||||||
|
if (!text) {
|
||||||
|
return renderMain.call(this, text)
|
||||||
|
}
|
||||||
|
|
||||||
callHook(this, 'beforeEach', text, result => {
|
callHook(this, 'beforeEach', text, result => {
|
||||||
const html = this.isHTML ? result : markdown(result)
|
let html = this.isHTML ? result : this.compiler.compile(result)
|
||||||
|
if (opt.updatedAt) {
|
||||||
|
html = formatUpdated(html, opt.updatedAt, this.config.formatUpdated)
|
||||||
|
}
|
||||||
|
|
||||||
callHook(this, 'afterEach', html, text => renderMain.call(this, text))
|
callHook(this, 'afterEach', html, text => renderMain.call(this, text))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -111,7 +139,7 @@ export function renderMixin (proto) {
|
|||||||
}
|
}
|
||||||
dom.toggleClass(el, 'add', 'show')
|
dom.toggleClass(el, 'add', 'show')
|
||||||
|
|
||||||
let html = this.coverIsHTML ? text : cover(text)
|
let html = this.coverIsHTML ? text : this.compiler.cover(text)
|
||||||
const m = html.trim().match('<p><img.*?data-origin="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$')
|
const m = html.trim().match('<p><img.*?data-origin="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$')
|
||||||
|
|
||||||
if (m) {
|
if (m) {
|
||||||
@@ -122,7 +150,7 @@ export function renderMixin (proto) {
|
|||||||
|
|
||||||
dom.toggleClass(el, 'add', 'has-mask')
|
dom.toggleClass(el, 'add', 'has-mask')
|
||||||
if (!isAbsolutePath(m[1])) {
|
if (!isAbsolutePath(m[1])) {
|
||||||
path = getPath(getBasePath(this.config.basePath), m[1])
|
path = getPath(this.router.getBasePath(), m[1])
|
||||||
}
|
}
|
||||||
el.style.backgroundImage = `url(${path})`
|
el.style.backgroundImage = `url(${path})`
|
||||||
el.style.backgroundSize = 'cover'
|
el.style.backgroundSize = 'cover'
|
||||||
@@ -136,7 +164,6 @@ export function renderMixin (proto) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proto._updateRender = function () {
|
proto._updateRender = function () {
|
||||||
markdown.update()
|
|
||||||
// render name link
|
// render name link
|
||||||
renderNameLink(this)
|
renderNameLink(this)
|
||||||
}
|
}
|
||||||
@@ -146,40 +173,50 @@ export function initRender (vm) {
|
|||||||
const config = vm.config
|
const config = vm.config
|
||||||
|
|
||||||
// Init markdown compiler
|
// Init markdown compiler
|
||||||
markdown.init(config.markdown, config.basePath)
|
vm.compiler = new Compiler(config, vm.router)
|
||||||
|
|
||||||
const id = config.el || '#app'
|
const id = config.el || '#app'
|
||||||
const navEl = dom.find('nav') || dom.create('nav')
|
const navEl = dom.find('nav') || dom.create('nav')
|
||||||
|
|
||||||
let el = dom.find(id)
|
const el = dom.find(id)
|
||||||
let html = ''
|
let html = ''
|
||||||
|
let navAppendToTarget = dom.body
|
||||||
|
|
||||||
navEl.classList.add('app-nav')
|
if (el) {
|
||||||
|
if (config.repo) {
|
||||||
|
html += tpl.corner(config.repo)
|
||||||
|
}
|
||||||
|
if (config.coverpage) {
|
||||||
|
html += tpl.cover()
|
||||||
|
}
|
||||||
|
|
||||||
if (!config.repo) {
|
html += tpl.main(config)
|
||||||
navEl.classList.add('no-badge')
|
// Render main app
|
||||||
|
vm._renderTo(el, html, true)
|
||||||
|
} else {
|
||||||
|
vm.rendered = true
|
||||||
}
|
}
|
||||||
if (!el) {
|
|
||||||
el = dom.create(id)
|
if (config.mergeNavbar && isMobile) {
|
||||||
dom.appendTo(dom.body, el)
|
navAppendToTarget = dom.find('.sidebar')
|
||||||
}
|
} else {
|
||||||
if (config.repo) {
|
navEl.classList.add('app-nav')
|
||||||
html += tpl.corner(config.repo)
|
|
||||||
}
|
if (!config.repo) {
|
||||||
if (config.coverpage) {
|
navEl.classList.add('no-badge')
|
||||||
html += tpl.cover()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
html += tpl.main(config)
|
|
||||||
// Render main app
|
|
||||||
vm._renderTo(el, html, true)
|
|
||||||
// Add nav
|
// Add nav
|
||||||
dom.before(dom.body, navEl)
|
dom.before(navAppendToTarget, navEl)
|
||||||
|
|
||||||
if (config.themeColor) {
|
if (config.themeColor) {
|
||||||
dom.$.head.innerHTML += tpl.theme(config.themeColor)
|
dom.$.head.appendChild(
|
||||||
|
dom.create('div', tpl.theme(config.themeColor)).firstElementChild
|
||||||
|
)
|
||||||
// Polyfll
|
// Polyfll
|
||||||
cssVars(config.themeColor)
|
cssVars(config.themeColor)
|
||||||
}
|
}
|
||||||
|
vm._updateRender()
|
||||||
dom.toggleClass(dom.body, 'ready')
|
dom.toggleClass(dom.body, 'ready')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ export function main (config) {
|
|||||||
(config.name
|
(config.name
|
||||||
? `<h1><a class="app-name-link" data-nosearch>${config.name}</a></h1>`
|
? `<h1><a class="app-name-link" data-nosearch>${config.name}</a></h1>`
|
||||||
: '') +
|
: '') +
|
||||||
'<div class="sidebar-nav"></div>' +
|
'<div class="sidebar-nav"><!--sidebar--></div>' +
|
||||||
'</aside>')
|
'</aside>')
|
||||||
|
|
||||||
return (isMobile ? `${aside}<main>` : `<main>${aside}`) +
|
return (isMobile ? `${aside}<main>` : `<main>${aside}`) +
|
||||||
'<section class="content">' +
|
'<section class="content">' +
|
||||||
'<article class="markdown-section" id="main"></article>' +
|
'<article class="markdown-section" id="main"><!--main--></article>' +
|
||||||
'</section>' +
|
'</section>' +
|
||||||
'</main>'
|
'</main>'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
import { merge, cached } from '../util/core'
|
|
||||||
import { parseQuery, stringifyQuery, cleanPath } from './util'
|
|
||||||
export * from './util'
|
|
||||||
|
|
||||||
function replaceHash (path) {
|
|
||||||
const i = window.location.href.indexOf('#')
|
|
||||||
window.location.replace(
|
|
||||||
window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const replaceSlug = cached(path => {
|
|
||||||
return path
|
|
||||||
.replace('#', '?id=')
|
|
||||||
.replace(/\?(\w+)=/g, (_, slug) => slug === 'id' ? '?id=' : `&${slug}=`)
|
|
||||||
})
|
|
||||||
/**
|
|
||||||
* Normalize the current url
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* domain.com/docs/ => domain.com/docs/#/
|
|
||||||
* domain.com/docs/#/#slug => domain.com/docs/#/?id=slug
|
|
||||||
*/
|
|
||||||
export function normalize () {
|
|
||||||
let path = getHash()
|
|
||||||
|
|
||||||
path = replaceSlug(path)
|
|
||||||
|
|
||||||
if (path.charAt(0) === '/') return replaceHash(path)
|
|
||||||
replaceHash('/' + path)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getHash () {
|
|
||||||
// We can't use window.location.hash here because it's not
|
|
||||||
// consistent across browsers - Firefox will pre-decode it!
|
|
||||||
const href = window.location.href
|
|
||||||
const index = href.indexOf('#')
|
|
||||||
return index === -1 ? '' : href.slice(index + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse the url
|
|
||||||
* @param {string} [path=window.location.herf]
|
|
||||||
* @return {object} { path, query }
|
|
||||||
*/
|
|
||||||
export function parse (path = window.location.href) {
|
|
||||||
let query = ''
|
|
||||||
|
|
||||||
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, query: parseQuery(query) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* to URL
|
|
||||||
* @param {string} path
|
|
||||||
* @param {object} qs query params
|
|
||||||
*/
|
|
||||||
export function toURL (path, params) {
|
|
||||||
const route = parse(replaceSlug(path))
|
|
||||||
|
|
||||||
route.query = merge({}, route.query, params)
|
|
||||||
path = route.path + stringifyQuery(route.query)
|
|
||||||
|
|
||||||
return cleanPath('#/' + path)
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import { normalize, parse } from './hash'
|
|
||||||
import { getBasePath, getPath, isAbsolutePath } from './util'
|
|
||||||
import { on } from '../util/dom'
|
|
||||||
|
|
||||||
function getAlias (path, alias) {
|
|
||||||
return alias[path] ? getAlias(alias[path], alias) : path
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFileName (path) {
|
|
||||||
return /\.(md|html)$/g.test(path)
|
|
||||||
? path
|
|
||||||
: /\/$/g.test(path)
|
|
||||||
? `${path}README.md`
|
|
||||||
: `${path}.md`
|
|
||||||
}
|
|
||||||
|
|
||||||
export function routeMixin (proto) {
|
|
||||||
proto.route = {}
|
|
||||||
proto.$getFile = function (path) {
|
|
||||||
const { config } = this
|
|
||||||
const base = getBasePath(config.basePath)
|
|
||||||
|
|
||||||
path = config.alias ? getAlias(path, config.alias) : path
|
|
||||||
path = getFileName(path)
|
|
||||||
path = path === '/README.md' ? (config.homepage || path) : path
|
|
||||||
path = isAbsolutePath(path) ? path : getPath(base, path)
|
|
||||||
|
|
||||||
return path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let lastRoute = {}
|
|
||||||
|
|
||||||
export function initRoute (vm) {
|
|
||||||
normalize()
|
|
||||||
lastRoute = vm.route = parse()
|
|
||||||
vm._updateRender()
|
|
||||||
|
|
||||||
on('hashchange', _ => {
|
|
||||||
normalize()
|
|
||||||
vm.route = parse()
|
|
||||||
vm._updateRender()
|
|
||||||
|
|
||||||
if (lastRoute.path === vm.route.path) {
|
|
||||||
vm.$resetEvents()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
vm.$fetch()
|
|
||||||
lastRoute = vm.route
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { History } from './base'
|
||||||
|
import { parseQuery, stringifyQuery, cleanPath } from '../util'
|
||||||
|
import { merge } from '../../util/core'
|
||||||
|
|
||||||
|
export class AbstractHistory extends History {
|
||||||
|
constructor (config) {
|
||||||
|
super(config)
|
||||||
|
this.mode = 'abstract'
|
||||||
|
}
|
||||||
|
|
||||||
|
parse (path) {
|
||||||
|
let query = ''
|
||||||
|
|
||||||
|
const queryIndex = path.indexOf('?')
|
||||||
|
if (queryIndex >= 0) {
|
||||||
|
query = path.slice(queryIndex + 1)
|
||||||
|
path = path.slice(0, queryIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
path,
|
||||||
|
file: this.getFile(path),
|
||||||
|
query: parseQuery(query)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toURL (path, params, currentRoute) {
|
||||||
|
const local = currentRoute && path[0] === '#'
|
||||||
|
const route = this.parse(path)
|
||||||
|
|
||||||
|
route.query = merge({}, route.query, params)
|
||||||
|
path = route.path + stringifyQuery(route.query)
|
||||||
|
path = path.replace(/\.md(\?)|\.md$/, '$1')
|
||||||
|
|
||||||
|
if (local) path = currentRoute + path
|
||||||
|
|
||||||
|
return cleanPath('/' + path)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { getPath, isAbsolutePath } from '../util'
|
||||||
|
import { noop } from '../../util/core'
|
||||||
|
|
||||||
|
const cached = {}
|
||||||
|
|
||||||
|
function getAlias (path, alias, last) {
|
||||||
|
const match = Object.keys(alias).filter((key) => {
|
||||||
|
const re = cached[key] || (cached[key] = new RegExp(`^${key}$`))
|
||||||
|
return re.test(path) && path !== last
|
||||||
|
})[0]
|
||||||
|
|
||||||
|
return match ? getAlias(path.replace(cached[match], alias[match]), alias, path) : path
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFileName (path) {
|
||||||
|
return /\.(md|html)$/g.test(path)
|
||||||
|
? path
|
||||||
|
: /\/$/g.test(path)
|
||||||
|
? `${path}README.md`
|
||||||
|
: `${path}.md`
|
||||||
|
}
|
||||||
|
|
||||||
|
export class History {
|
||||||
|
constructor (config) {
|
||||||
|
this.config = config
|
||||||
|
}
|
||||||
|
|
||||||
|
getBasePath () {
|
||||||
|
return this.config.basePath
|
||||||
|
}
|
||||||
|
|
||||||
|
getFile (path, isRelative) {
|
||||||
|
path = path || this.getCurrentPath()
|
||||||
|
|
||||||
|
const { config } = this
|
||||||
|
const base = this.getBasePath()
|
||||||
|
|
||||||
|
path = config.alias ? getAlias(path, config.alias) : path
|
||||||
|
path = getFileName(path)
|
||||||
|
path = path === '/README.md' ? (config.homepage || path) : path
|
||||||
|
path = isAbsolutePath(path) ? path : getPath(base, path)
|
||||||
|
|
||||||
|
if (isRelative) {
|
||||||
|
path = path.replace(new RegExp(`^${base}`), '')
|
||||||
|
}
|
||||||
|
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
onchange (cb = noop) {
|
||||||
|
cb()
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentPath () {}
|
||||||
|
|
||||||
|
normalize () {}
|
||||||
|
|
||||||
|
parse () {}
|
||||||
|
|
||||||
|
toURL () {}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user