@@ -6,41 +6,41 @@ A plugin is simply a function that takes `hook` as an argument. The hook support
66
77``` js
88window .$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+ };
4444```
4545
4646!> 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.
5454``` js
5555window .$docsify = {
5656 plugins: [
57- function (hook ) {
57+ function (hook ) {
5858 var footer = [
5959 ' <hr/>' ,
6060 ' <footer>' ,
6161 ' <span><a href="https://github.com/QingWei-Li">cinwell</a> ©2017.</span>' ,
6262 ' <span>Proudly published with <a href="https://github.com/docsifyjs/docsify" target="_blank">docsify</a>.</span>' ,
6363 ' </footer>'
64- ].join (' ' )
64+ ].join (' ' );
6565
66- hook .afterEach (function (html ) {
67- return html + footer
68- })
66+ hook .afterEach (function (html ) {
67+ return html + footer;
68+ });
6969 }
7070 ]
71- }
71+ };
7272```
7373
7474### Edit Button
@@ -77,17 +77,35 @@ window.$docsify = {
7777window .$docsify = {
7878 plugins: [
7979 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+ });
9094 }
9195 ]
92- }
96+ };
9397```
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