kubernetes-handbook/gitbook/gitbook-plugin-editlink/plugin.js

23 lines
624 B
JavaScript
Raw Normal View History

2017-08-21 17:44:43 +08:00
require(["gitbook", "jQuery"], function(gitbook, $) {
gitbook.events.bind('start', function (e, config) {
var conf = config.editlink
var label = conf.label
var base = conf.base
var multilingual = conf.multilingual || false
if (base.slice(-1) !== "/") {
base += "/"
}
gitbook.toolbar.createButton({
icon: 'fa fa-edit',
text: label,
onClick: function() {
var filepath = gitbook.state.filepath
var lang = multilingual && $('html').attr('lang') ? $('html').attr('lang') + '/' : ''
window.open(base + lang + filepath)
}
})
})
})