Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "gitbook/plugin"
}
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules

# Plugin assets
_assets/plugin.js
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Publish assets on NPM
!_assets/plugin.js
14 changes: 0 additions & 14 deletions assets/plugin.js

This file was deleted.

Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 5 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
module.exports = {

website: {
assets: './assets',
js: [
'plugin.js'
]
}
blocks: {

},
hooks: {

}
};
21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"title": "GitHub",
"name": "gitbook-plugin-github",
"version": "2.0.0",
"description": "Display a link to your GitHub repo in your gitbook",
"icon": "./icon.png",
"description": "Integrate your website with your GitHub repository.",
"main": "index.js",
"browser": "./_assets/plugin.js",
"authors": [
{
"name": "Michael Jackson"
Expand All @@ -12,20 +15,32 @@
"email": "samy@gitbook.com"
}
],
"devDependencies": {
"gitbook-plugin": "^4.0.0-alpha.0",
"eslint": "^3.7.1",
"eslint-config-gitbook": "^1.5.0"
},
"repository": {
"type": "git",
"url": "https://github.com/GitbookIO/plugin-github.git"
},
"license": "Apache-2.0",
"engines": {
"gitbook": ">=2.5.0"
"gitbook": ">=4.0.0-alpha.0"
},
"keywords": [
"gitbook:social"
],
"scripts": {
"build-js": "gitbook-plugin build ./src/index.js ./_assets/plugin.js",
"prepublish": "npm run build-js"
},
"gitbook": {
"properties": {
"url": {
"type": "string",
"required": true,
"title": "URL to your GitHub repository"
"title": "URL of your GitHub repository"
}
}
}
Expand Down
31 changes: 31 additions & 0 deletions src/GitHubButtons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const GitBook = require('gitbook-core');
const { React } = GitBook;

/**
* Render button in toolbar for the GitHub repository.
* @type {ReactClass}
*/
const GitHubButtons = React.createClass({
propTypes: {
url: React.PropTypes.string.isRequired
},

onOpen() {
const { url } = this.props;
window.open(url);
},

render() {
return (
<GitBook.ButtonGroup>
<GitBook.Button title="GitHub" onClick={this.onOpen}>
<GitBook.Icon id="github" />
</GitBook.Button>
</GitBook.ButtonGroup>
);
}
});

module.exports = GitBook.connect(GitHubButtons, ({ config }) => ({
url: config.getForPlugin('github').get('url')
}));
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const GitBook = require('gitbook-core');
const GitHubButtons = require('./GitHubButtons');

module.exports = GitBook.createPlugin({
activate: (dispatch, getState, { Components }) => {
dispatch(Components.registerComponent(GitHubButtons, { role: 'toolbar:buttons:right' }));
}
});
Loading