summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/gitbook-plugin-sharing/.gitignore2
-rw-r--r--packages/gitbook-plugin-sharing/.npmignore2
-rw-r--r--packages/gitbook-plugin-sharing/package.json8
-rw-r--r--packages/gitbook-plugin-sharing/src/index.js30
-rw-r--r--packages/gitbook/package.json2
5 files changed, 35 insertions, 9 deletions
diff --git a/packages/gitbook-plugin-sharing/.gitignore b/packages/gitbook-plugin-sharing/.gitignore
index 7c6f0eb..ef47881 100644
--- a/packages/gitbook-plugin-sharing/.gitignore
+++ b/packages/gitbook-plugin-sharing/.gitignore
@@ -28,4 +28,4 @@ node_modules
*.swp
# Plugin assets
-_assets
+_assets/plugin.js
diff --git a/packages/gitbook-plugin-sharing/.npmignore b/packages/gitbook-plugin-sharing/.npmignore
index 7bc36b7..a0e53cf 100644
--- a/packages/gitbook-plugin-sharing/.npmignore
+++ b/packages/gitbook-plugin-sharing/.npmignore
@@ -1,2 +1,2 @@
# Publish assets on NPM
-!_assets
+!_assets/plugin.js
diff --git a/packages/gitbook-plugin-sharing/package.json b/packages/gitbook-plugin-sharing/package.json
index 1519136..21fc038 100644
--- a/packages/gitbook-plugin-sharing/package.json
+++ b/packages/gitbook-plugin-sharing/package.json
@@ -1,9 +1,9 @@
{
"name": "gitbook-plugin-sharing",
- "description": "Sharing button in the toolbar",
+ "description": "Sharing buttons in the toolbar",
"main": "index.js",
- "browser": "./_assets/theme.js",
- "version": "0.0.0",
+ "browser": "./_assets/plugin.js",
+ "version": "4.0.0",
"dependencies": {
"gitbook-core": "^0.0.0"
},
@@ -14,7 +14,7 @@
"gitbook": ">=3.0.0"
},
"scripts": {
- "build-js": "gitbook-plugin build ./src/index.js ./_assets/theme.js",
+ "build-js": "gitbook-plugin build ./src/index.js ./_assets/plugin.js",
"prepublish": "npm run build-js"
},
"homepage": "https://github.com/GitbookIO/gitbook",
diff --git a/packages/gitbook-plugin-sharing/src/index.js b/packages/gitbook-plugin-sharing/src/index.js
index e3ffdfb..4821de2 100644
--- a/packages/gitbook-plugin-sharing/src/index.js
+++ b/packages/gitbook-plugin-sharing/src/index.js
@@ -1,8 +1,34 @@
const GitBook = require('gitbook-core');
+const { React } = GitBook;
module.exports = GitBook.createPlugin({
- activate: (dispatch, getState) => {
-
+ activate: (dispatch, getState, { Components }) => {
+ // Dispatch initialization actions
+ dispatch(Components.registerComponent(SharingButton, { role: 'toolbar:buttons:right' }))
+ },
+ deactivate: (dispatch, getState) => {
+ // Dispatch cleanup actions
},
reduce: (state, action) => state
});
+
+let SharingButton = React.createClass({
+ propTypes: {
+ page: GitBook.Shapes.Page
+ },
+
+ onClick() {
+ alert(this.props.page.title)
+ },
+
+ render() {
+ return (
+ <GitBook.Button onClick={this.onClick}>
+ <GitBook.Icon id="facebook"/>
+ </GitBook.Button>
+ )
+ }
+})
+SharingButton = GitBook.connect(SharingButton, function mapStateToProps(state) {
+ return { page: state.page }
+})
diff --git a/packages/gitbook/package.json b/packages/gitbook/package.json
index 1b6c0ef..12b190a 100644
--- a/packages/gitbook/package.json
+++ b/packages/gitbook/package.json
@@ -29,7 +29,7 @@
"gitbook-plugin-livereload": "0.0.1",
"gitbook-plugin-lunr": "1.2.0",
"gitbook-plugin-search": "2.2.1",
- "gitbook-plugin-sharing": "1.0.2",
+ "gitbook-plugin-sharing": "4.0.0",
"gitbook-plugin-theme-default": "1.0.5",
"gitbook-plugin-hints": "2.0.0",
"github-slugid": "1.0.1",