Gitbook plugin add "edit this page" link, and intelligent recognition to Github or Gitlab source repository.
book.json
filebook.json
file, add edit-link-plus
to plugins
list.pluginsConfig
, Set base
value which is base path to your github or gitlab or other code repo. Trailing slash is NOT required.label
.pluginsConfig
, Set defaultBase
value 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
}
gitbook install
. It will automatically install edit-link-plus
gitbook plugin for your book. This is needed only once.gitbook install
or you can run npm install gitbook-plugin-edit-link-plus
to install locally.
npm install gitbook-plugin-edit-link-plus
gitbook build
) or serve (gitbook serve
) as usual.gitbook serve
https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/blob/master/docs/book.json[5]
{
"plugins": ["edit-link-plus"],
"pluginsConfig": {
"edit-link-plus": {
"base": {
"snowdreams1006.github.io":"https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/edit/master/docs",
"snowdreams1006.gitlab.io":"https://gitlab.com/snowdreams1006/gitbook-plugin-edit-link-plus/edit/master/docs",
"snowdreams1006.gitee.io":"https://gitee.com/snowdreams1006/gitbook-plugin-edit-link-plus/edit/master/docs"
},
"defaultBase": "https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/edit/master/docs",
"label": "Edit This Page"
}
}
}
https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/blob/master/example/book.json[6]
{
"plugins": ["edit-link-plus"],
"pluginsConfig": {
"edit-link-plus": {
"base": "https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/edit/master/example"
}
}
}
book.json
file{
"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": "点我反馈"
}
}
}
book.json
file for Multi-source base{
"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"
}
}
}
book.json
file for multilingual labels{
"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
Contributions, issues and feature requests are welcome!
Feel free to check issues page[10].
Give a **Star**[11] if this project helped you!
Copyright © 2019 snowdreams1006[12].
This project is MIT[13] licensed.
book.json
is valid. You can use this online tool - http://json.parser.online.fr/beta/[16]Homepage: https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus#readme
[2]https://snowdreams1006.github.io/gitbook-plugin-edit-link-plus/: https://snowdreams1006.github.io/gitbook-plugin-edit-link-plus/
[3]https://snowdreams1006.gitlab.io/gitbook-plugin-edit-link-plus/: https://snowdreams1006.gitlab.io/gitbook-plugin-edit-link-plus/
[4]https://snowdreams1006.gitee.io/gitbook-plugin-edit-link-plus/: https://snowdreams1006.gitee.io/gitbook-plugin-edit-link-plus/
[5]https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/blob/master/docs/book.json: https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/blob/master/docs/book.json
[6]https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/blob/master/example/book.json: https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/blob/master/example/book.json
[7]snowdreams1006.tech: https://snowdreams1006.tech/
[8]@snowdreams1006: https://github.com/snowdreams1006
[9]snowdreams1006@163.com: mailto:snowdreams1006@163.com
[10]issues page: https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/issues
[11]Star: https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus
[12]snowdreams1006: https://github.com/snowdreams1006
[13]MIT: https://github.com/snowdreams1006/gitbook-plugin-edit-link-plus/blob/master/LICENSE
[14]gitbook-plugin-editlink: https://github.com/zhaoda/gitbook-plugin-editlink
[15]gitbook-plugin-edit-link: https://github.com/rtCamp/gitbook-plugin-edit-link
[16]http://json.parser.online.fr/beta/: http://json.parser.online.fr/beta/