@@ -6,41 +6,41 @@ A plugin is simply a function that takes `hook` as an argument. The hook support
6
6
7
7
``` js
8
8
window .$docsify = {
9
- plugins: [
10
- function (hook , vm ) {
11
- hook .init (function () {
12
- // Called when the script starts running, only trigger once, no arguments,
13
- })
14
-
15
- hook .beforeEach (function (content ) {
16
- // Invoked each time before parsing the Markdown file.
17
- // ...
18
- return content
19
- })
20
-
21
- hook .afterEach (function (html , next ) {
22
- // Invoked each time after the Markdown file is parsed.
23
- // beforeEach and afterEach support asynchronous。
24
- // ...
25
- // call `next(html)` when task is done.
26
- next (html)
27
- })
28
-
29
- hook .doneEach (function () {
30
- // Invoked each time after the data is fully loaded, no arguments,
31
- // ...
32
- })
33
-
34
- hook .mounted (function () {
35
- // Called after initial completion. Only trigger once, no arguments.
36
- })
37
-
38
- hook .ready (function () {
39
- // Called after initial completion, no arguments.
40
- })
41
- }
42
- ]
43
- }
9
+ plugins: [
10
+ function (hook , vm ) {
11
+ hook .init (function () {
12
+ // Called when the script starts running, only trigger once, no arguments,
13
+ });
14
+
15
+ hook .beforeEach (function (content ) {
16
+ // Invoked each time before parsing the Markdown file.
17
+ // ...
18
+ return content;
19
+ });
20
+
21
+ hook .afterEach (function (html , next ) {
22
+ // Invoked each time after the Markdown file is parsed.
23
+ // beforeEach and afterEach support asynchronous。
24
+ // ...
25
+ // call `next(html)` when task is done.
26
+ next (html);
27
+ });
28
+
29
+ hook .doneEach (function () {
30
+ // Invoked each time after the data is fully loaded, no arguments,
31
+ // ...
32
+ });
33
+
34
+ hook .mounted (function () {
35
+ // Called after initial completion. Only trigger once, no arguments.
36
+ });
37
+
38
+ hook .ready (function () {
39
+ // Called after initial completion, no arguments.
40
+ });
41
+ }
42
+ ]
43
+ };
44
44
```
45
45
46
46
!> You can get internal methods through ` window.Docsify ` . Get the current instance through the second argument.
@@ -54,21 +54,21 @@ Add footer component in each pages.
54
54
``` js
55
55
window .$docsify = {
56
56
plugins: [
57
- function (hook ) {
57
+ function (hook ) {
58
58
var footer = [
59
59
' <hr/>' ,
60
60
' <footer>' ,
61
61
' <span><a href="https://github.com/QingWei-Li">cinwell</a> ©2017.</span>' ,
62
62
' <span>Proudly published with <a href="https://github.com/docsifyjs/docsify" target="_blank">docsify</a>.</span>' ,
63
63
' </footer>'
64
- ].join (' ' )
64
+ ].join (' ' );
65
65
66
- hook .afterEach (function (html ) {
67
- return html + footer
68
- })
66
+ hook .afterEach (function (html ) {
67
+ return html + footer;
68
+ });
69
69
}
70
70
]
71
- }
71
+ };
72
72
```
73
73
74
74
### Edit Button
@@ -77,17 +77,35 @@ window.$docsify = {
77
77
window .$docsify = {
78
78
plugins: [
79
79
function (hook , vm ) {
80
- hook .beforeEach (function (html ) {
81
- var url = ' https://github.com/docsifyjs/docsify/blob/master/docs' + vm .route .file
82
- var editHtml = ' [📝 EDIT DOCUMENT](' + url + ' )\n '
83
-
84
- return editHtml
85
- + html
86
- + ' \n ----\n '
87
- + ' Last modified {docsify-updated} '
88
- + editHtml
89
- })
80
+ hook .beforeEach (function (html ) {
81
+ var url =
82
+ ' https://github.com/docsifyjs/docsify/blob/master/docs' +
83
+ vm .route .file ;
84
+ var editHtml = ' [📝 EDIT DOCUMENT](' + url + ' )\n ' ;
85
+
86
+ return (
87
+ editHtml +
88
+ html +
89
+ ' \n ----\n ' +
90
+ ' Last modified {docsify-updated} ' +
91
+ editHtml
92
+ );
93
+ });
90
94
}
91
95
]
92
- }
96
+ };
93
97
```
98
+
99
+ ## Tips
100
+
101
+ ### Get docsify version
102
+
103
+ ```
104
+ console.log(window.Docsify.version)
105
+ ```
106
+
107
+ Current version: <span id =' tip-version ' >loading</span >
108
+
109
+ <script >
110
+ document .getElementById (' tip-version' ).innerText = Docsify .version
111
+ </script >
0 commit comments