diff options
Diffstat (limited to 'packages/gitbook-plugin-headings')
-rw-r--r-- | packages/gitbook-plugin-headings/.gitignore | 31 | ||||
-rw-r--r-- | packages/gitbook-plugin-headings/.npmignore | 2 | ||||
-rw-r--r-- | packages/gitbook-plugin-headings/index.js | 10 | ||||
-rw-r--r-- | packages/gitbook-plugin-headings/package.json | 28 | ||||
-rw-r--r-- | packages/gitbook-plugin-headings/src/index.js | 27 |
5 files changed, 98 insertions, 0 deletions
diff --git a/packages/gitbook-plugin-headings/.gitignore b/packages/gitbook-plugin-headings/.gitignore new file mode 100644 index 0000000..ef47881 --- /dev/null +++ b/packages/gitbook-plugin-headings/.gitignore @@ -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 diff --git a/packages/gitbook-plugin-headings/.npmignore b/packages/gitbook-plugin-headings/.npmignore new file mode 100644 index 0000000..a0e53cf --- /dev/null +++ b/packages/gitbook-plugin-headings/.npmignore @@ -0,0 +1,2 @@ +# Publish assets on NPM +!_assets/plugin.js diff --git a/packages/gitbook-plugin-headings/index.js b/packages/gitbook-plugin-headings/index.js new file mode 100644 index 0000000..e542ae8 --- /dev/null +++ b/packages/gitbook-plugin-headings/index.js @@ -0,0 +1,10 @@ + +module.exports = { + blocks: { + + }, + + hooks: { + + } +}; diff --git a/packages/gitbook-plugin-headings/package.json b/packages/gitbook-plugin-headings/package.json new file mode 100644 index 0000000..52c69d8 --- /dev/null +++ b/packages/gitbook-plugin-headings/package.json @@ -0,0 +1,28 @@ +{ + "name": "gitbook-plugin-headings", + "description": "Automatically add anchors to headings", + "main": "index.js", + "browser": "./_assets/plugin.js", + "version": "1.0.0", + "dependencies": { + "gitbook-core": "^0.0.0" + }, + "devDependencies": { + "gitbook-plugin": "*" + }, + "engines": { + "gitbook": ">=3.0.0" + }, + "scripts": { + "build-js": "gitbook-plugin build ./src/index.js ./_assets/plugin.js", + "prepublish": "npm run build-js" + }, + "homepage": "https://github.com/GitbookIO/gitbook", + "repository": { + "type": "git", + "url": "https://github.com/GitbookIO/gitbook.git" + }, + "bugs": { + "url": "https://github.com/GitbookIO/gitbook/issues" + } +} diff --git a/packages/gitbook-plugin-headings/src/index.js b/packages/gitbook-plugin-headings/src/index.js new file mode 100644 index 0000000..00bc790 --- /dev/null +++ b/packages/gitbook-plugin-headings/src/index.js @@ -0,0 +1,27 @@ +const GitBook = require('gitbook-core'); +const { React } = GitBook; + +const Heading = React.createClass({ + propTypes: { + children: React.PropTypes.node + }, + + render() { + return ( + <div className="Headings-Container"> + {this.props.children} + </div> + ); + } +}); + +module.exports = GitBook.createPlugin({ + activate: (dispatch, getState, { Components }) => { + // Dispatch initialization actions + dispatch(Components.registerComponent(Heading, { role: 'html:h1' })); + }, + deactivate: (dispatch, getState) => { + // Dispatch cleanup actions + }, + reduce: (state, action) => state +}); |