Skip to content
This repository was archived by the owner on Oct 27, 2020. It is now read-only.

Commit e9f50d7

Browse files
committed
Fix for missing page:after hook in gitbook 2.0.1
1 parent 754ec7a commit e9f50d7

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ Link target will be that page's source file on Github or Gitlab or any repo.
1717
2. In `pluginsConfig`, Set `base` value which is base path to your github or gitlab or other code repo. Trailing slash is NOT required.
1818
3. By default link label will be "Edit This Page". You can change it using plugin config `label`.
1919

20-
#### Sample `book.json` file
20+
#### Sample `book.json` file for gitbook version 2.0.1 and above
2121

2222
```
2323
{
24+
"gitbook": "2.0.1",
2425
"plugins": ["edit-link"],
2526
"pluginsConfig": {
2627
"edit-link": {
@@ -30,6 +31,22 @@ Link target will be that page's source file on Github or Gitlab or any repo.
3031
}
3132
}
3233
```
34+
35+
#### Sample `book.json` file for older gitbook versions <= 1.5.0
36+
37+
```
38+
{
39+
"gitbook": "1.5.0",
40+
"plugins": ["[email protected]"],
41+
"pluginsConfig": {
42+
"edit-link": {
43+
"base": "https://github.com/USER/REPO/edit/BRANCH/path/to/book",
44+
"label": "Edit This Page"
45+
}
46+
}
47+
}
48+
```
49+
3350
**Note**: Above snippet can be used as complete `book.json` file, if your book doesn't have one yet.
3451

3552
**Github/Gitlab**: In string `...REPO/edit/BRANCH...`, you may replace `edit` with `tree` if you want source file to open in read-mode, rather than edit-mode directly on github/gitlab.
@@ -44,6 +61,16 @@ Link target will be that page's source file on Github or Gitlab or any repo.
4461
1. If you are not seeing the "Edit this page" link, check if your `book.json` is valid. You can use this online tool - [http://json.parser.online.fr/beta/](http://json.parser.online.fr/beta/)
4562
2. Check if you are using default gitbook theme. It is NOT recommended to modify gitbook themes directly.
4663

64+
## Known Issue
65+
66+
Gitbook 2.0.1 has removed `page:after` hook which this plugin needs. An issue has been reported here - https://github.com/GitbookIO/gitbook/issues/724 but meanwhile this plugin is using workaround added by this pull request - https://github.com/rtCamp/gitbook-plugin-edit-link/pull/4
67+
68+
So when using Gitbook 2.0.1, you may see following warning in console at the time of running build:
69+
70+
> warn: hook 'page' used by plugin 'gitbook-plugin-edit-link' is deprecated, and will be remove in the coming versions
71+
72+
You can safely ignore above warning for now.
73+
4774
## How this work?
4875

4976
This plugin simply looks for HTML comment `<!-- Actions Right -->` in parsed page content and insert "edit link" HTML just before `<!-- Actions Right -->`.
@@ -52,6 +79,10 @@ This means if that HTML comment changes, this plugin will break but I hope to fi
5279

5380
## Changelog
5481

82+
**1.3 - 28 April 2015**
83+
84+
- Gitbook 2.0.1 compatibility added by [@todvora](https://github.com/rtCamp/gitbook-plugin-edit-link/pull/4). Please see known-issues for more details.
85+
5586
**1.2 - 03 April 2015**
5687

5788
- Multiligual gitbook support added by [@aniav](https://github.com/aniav) ([#2](https://github.com/rtCamp/gitbook-plugin-edit-link/pull/2))

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"keywords": [
2424
"gitbook",
2525
"plugin",
26-
"edit-with"
26+
"edit-with",
27+
"github"
2728
]
2829
}

0 commit comments

Comments
 (0)