Skip to content
Open
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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Plugin assets
_assets/plugin.js
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "gitbook/plugin"
}
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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

# vim swapfile
*.swp

# 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.

14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

module.exports = {

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

},

hooks: {

}
};
74 changes: 46 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
{
"name": "gitbook-plugin-github",
"version": "2.0.0",
"description": "Display a link to your GitHub repo in your gitbook",
"main": "index.js",
"authors": [
{
"name": "Michael Jackson"
},
{
"name": "Samy Pessé",
"email": "samy@gitbook.com"
}
],
"repository": {
"type": "git",
"url": "https://github.com/GitbookIO/plugin-github.git"
"title": "Github Sharing",
"name": "gitbook-plugin-github",
"version": "2.0.0",
"description": "Display a link to your GitHub repo in your gitbook",
"keywords": ["gitbook:social", "github", "sharing", "repository"],
"main": "index.js",
"authors": [
{
"name": "Michael Jackson"
},
"license": "Apache-2.0",
"engines": {
"gitbook": ">=2.5.0"
},
"gitbook": {
"properties": {
"url": {
"type": "string",
"required": true,
"title": "URL to your GitHub repository"
}
}
{
"name": "Samy Pessé",
"email": "samy@gitbook.com"
}
],
"repository": {
"type": "git",
"url": "https://github.com/GitbookIO/plugin-github.git"
},
"license": "Apache-2.0",
"browser": "./_assets/plugin.js",
"ebook": "./_assets/plugin.js",
"dependencies": {
"gitbook-core": "^4.0.0"
},
"devDependencies": {
"gitbook-plugin": "^4.0.0",
"eslint": "3.7.1",
"eslint-config-gitbook": "1.4.0"
},
"engines": {
"gitbook": ">=4.0.0-alpha.0"
},
"gitbook": {
"properties": {
"url": {
"type": "string",
"required": true,
"title": "URL to your GitHub repository"
}
}
},
"scripts": {
"lint": "eslint ./",
"build-website": "gitbook-plugin build ./src/index.js ./_assets/plugin.js",
"prepublish": "npm run build-website",
"test": "gitbook-plugin test && npm run lint"
}
}
34 changes: 34 additions & 0 deletions src/components/GitHubButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const GitBook = require('gitbook-core');
const { React } = GitBook;

/**
* Display a button that links to the GitHub repository
*/
const SharingButtons = React.createClass({
propTypes: {
url: React.PropTypes.string.isRequired
},

render() {
const { url } = this.props;

return (
<GitBook.ButtonGroup>
<GitBook.Button active={Boolean(url)}
onClick={() => window.open(url)}>
<GitBook.Icon id="github"/>
</GitBook.Button>
</GitBook.ButtonGroup>
);
}
});

function mapStateToProps(state) {
const url = state.config.getIn(['pluginsConfig', 'github', 'url']);

return {
url
};
}

module.exports = GitBook.connect(SharingButtons, mapStateToProps);
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const GitBook = require('gitbook-core');
const GitHubButton = require('./components/GitHubButton');

module.exports = GitBook.createPlugin({
activate: (dispatch, getState, { Components }) => {
// Dispatch initialization actions
dispatch(Components.registerComponent(GitHubButton, { role: 'toolbar:buttons:right' }));
}
});