Gitbook plugin add "edit this page" link, and intelligent recognition to Github or Gitlab source repository.
- In you gitbook's
book.jsonfile, addedit-link-plustopluginslist. - In
pluginsConfig, Setbasevalue which is base path to your github or gitlab or other code repo. Trailing slash is NOT required. - By default link label will be "Edit This Page". You can change it using plugin config
label. - In
pluginsConfig, SetdefaultBasevalue which is set as default base path to your github or gitlab or other code repo. Trailing slash is also NOT required.
Here is simplest example :
{ "plugins": ["edit-link-plus"], "pluginsConfig": { "edit-link-plus": { "base": "https://github.com/USER/REPO/edit/BRANCH/path/to/book" } } }In addition, the supported configuration options are as follows :
"base": { "type": [ "string", "object" ], "title": "Base for the edit redirection", "required": true }, "defaultBase": { "type": "string", "title": "Default base for the edit redirection", "required": false }, "label": { "type": [ "string", "object" ], "title": "Label for the edit button", "default": "Edit This Page", "required": false }- Run
gitbook install. It will automatically installedit-link-plusgitbook plugin for your book. This is needed only once.
gitbook installor you can run npm install gitbook-plugin-edit-link-plus to install locally.
npm install gitbook-plugin-edit-link-plus- Build your book (
gitbook build) or serve (gitbook serve) as usual.
gitbook serve{ "plugins": ["edit-link-plus"], "pluginsConfig": { "edit-link-plus": { "base": "https://github.com/USER/REPO/edit/BRANCH/path/to/book" } } }or you can add label to custom your label:
{ "plugins": ["edit-link-plus"], "pluginsConfig": { "edit-link-plus": { "base": "https://github.com/USER/REPO/edit/BRANCH/path/to/book", "label": "点我反馈" } } }{ "plugins": ["edit-link-plus"], "pluginsConfig": { "edit-link-plus": { "base": { "USER.github.io":"https://github.com/USER/REPO/edit/BRANCH/path/to/book", "USER.gitlab.io":"https://gitlab.com/USER/REPO/edit/BRANCH/path/to/book", "USER.gitee.io":"https://gitee.com/USER/REPO/edit/BRANCH/path/to/book", "CUSTOME DOMAIN":"https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/edit/master/docs" }, "defaultBase": "https://github.com/USER/REPO/edit/BRANCH/path/to/book", "label": "Edit This Page" } } }{ "plugins": ["edit-link-plus"], "pluginsConfig": { "edit-link-plus": { "base": "https://github.com/USER/REPO/edit/BRANCH/path/to/book", "label": { "en": "Edit This Page", "zh": "编辑本页" } } } }Note: Above snippet can be used as complete book.json file, if your book doesn't have one yet.
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.
👤 snowdreams1006
- Website: snowdreams1006.tech
- Github: @snowdreams1006
- Email: snowdreams1006@163.com
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a Star if this project helped you!
Copyright © 2019 snowdreams1006.
This project is MIT licensed.
- If you are not seeing the "Edit this page" link, check if your
book.jsonis valid. You can use this online tool - http://json.parser.online.fr/beta/ - Check if you are using default gitbook theme. It is NOT recommended to modify gitbook themes directly.
