mirror of
https://github.com/AskDavis/Getting-Started-With-ACPI.git
synced 2026-03-01 18:07:13 -08:00
Deploy acpi.dortania.ml to github.com/dortania/Getting-Started-With-ACPI.git:gh-pages
This commit is contained in:
50
gitbook/gitbook-plugin-github-edit/plugin.js
Normal file
50
gitbook/gitbook-plugin-github-edit/plugin.js
Normal file
@@ -0,0 +1,50 @@
|
||||
require([ 'gitbook' ], function (gitbook) {
|
||||
handleEditButton = function (e, config) {
|
||||
/**
|
||||
* [defaultOption: default option]
|
||||
* @type {Object}
|
||||
*/
|
||||
const defaultOption = {
|
||||
'url': 'https://github.com',
|
||||
'repo': 'aleen42/PersonalWiki',
|
||||
'branch': 'master'
|
||||
};
|
||||
|
||||
/** if users have its option, and then combine it with default options */
|
||||
if (config['github-edit']) {
|
||||
// @deprecated
|
||||
// if (this.options.pluginsConfig['page-treeview']) {
|
||||
for (var item in defaultOption) {
|
||||
/** special for copyright */
|
||||
// @deprecated
|
||||
const configOption = config['github-edit'];
|
||||
|
||||
// defaultOption[item] = this.options.pluginsConfig['page-treeview'][item] || defaultOption[item];
|
||||
if (item in configOption) {
|
||||
defaultOption[item] = configOption[item];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const configRoot = config['root'];
|
||||
|
||||
gitbook.toolbar.createButton({
|
||||
icon: 'fa fa-pencil-square-o ',
|
||||
label: 'Edit on GitHub',
|
||||
position: 'right',
|
||||
onClick: function () {
|
||||
window.open(defaultOption.url
|
||||
+ '/'
|
||||
+ defaultOption.repo
|
||||
+ '/edit/'
|
||||
+ defaultOption.branch
|
||||
+ (configRoot ? '/' + configRoot : '')
|
||||
+ '/'
|
||||
+ gitbook.state.filepath
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
gitbook.events.bind('start', handleEditButton);
|
||||
});
|
||||
Reference in New Issue
Block a user