-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2521c58
commit 855c450
Showing
14 changed files
with
322 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Write a plugin | ||
|
||
A plugin is simply a function that takes `hook` as arguments. | ||
The hook supports handling asynchronous tasks. | ||
|
||
## Full configuration | ||
|
||
```js | ||
window.$docsify = { | ||
plugins: [ | ||
function (hook, vm) { | ||
hook.init(function() { | ||
// Called when the script starts running, only trigger once, no arguments, | ||
}) | ||
|
||
hook.beforeEach(function(content) { | ||
// Invoked each time before parsing the Markdown file. | ||
// ... | ||
return content | ||
}) | ||
|
||
hook.afterEach(function(html, next) { | ||
// Invoked each time after the Markdown file is parsed. | ||
// beforeEach and afterEach support asynchronous。 | ||
// ... | ||
// call `next(html)` when task is done. | ||
next(html) | ||
}) | ||
|
||
hook.doneEach(function() { | ||
// Invoked each time after the data is fully loaded, no arguments, | ||
// ... | ||
}) | ||
|
||
hook.mounted(function() { | ||
// Called after initial completion. Only trigger once, no arguments. | ||
}) | ||
|
||
hook.ready(function() { | ||
// Called after initial completion, no arguments. | ||
}) | ||
} | ||
] | ||
} | ||
``` | ||
|
||
!> You can get internal methods through `window.Docsify`. Get the current instance through the second argument. | ||
|
||
## Example | ||
|
||
Add footer component in each pages. | ||
|
||
```js | ||
window.$docsify = { | ||
plugins: [ | ||
function (hook) { | ||
var footer = [ | ||
'<hr/>', | ||
'<footer>', | ||
'<span><a href="https://github.com/QingWei-Li">cinwell</a> ©2017.</span>', | ||
'<span>Proudly published with <a href="https://github.com/QingWei-Li/docsify" target="_blank">docsify</a>.</span>', | ||
'</footer>' | ||
].join('') | ||
|
||
hook.afterEach(function (html) { | ||
return html + footer | ||
}) | ||
} | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ docsify 是一个动态生成文档网站的工具。不同于 GitBook、Hexo | |
- 智能的全文搜索 | ||
- 提供多套主题 | ||
- 丰富的 API | ||
- 支持 Emoji | ||
- 兼容 IE10+ | ||
|
||
## 例子 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.