summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Preynat <johan.preynat@gmail.com>2016-10-05 20:14:08 +0200
committerJohan Preynat <johan.preynat@gmail.com>2016-10-05 20:14:08 +0200
commit6faf6a53f08d65f7e51724911473ad1832dcb2ba (patch)
treeda095dcca7700329e639e019362f9668be69f864
parentbced415a50d3031040a42cdc2cd3b02a2a241ff0 (diff)
downloadgitbook-6faf6a53f08d65f7e51724911473ad1832dcb2ba.zip
gitbook-6faf6a53f08d65f7e51724911473ad1832dcb2ba.tar.gz
gitbook-6faf6a53f08d65f7e51724911473ad1832dcb2ba.tar.bz2
Replace plugin fontsettings by creating plugin headings :hammer:
-rw-r--r--packages/gitbook-plugin-headings/.gitignore31
-rw-r--r--packages/gitbook-plugin-headings/.npmignore2
-rw-r--r--packages/gitbook-plugin-headings/index.js10
-rw-r--r--packages/gitbook-plugin-headings/package.json28
-rw-r--r--packages/gitbook-plugin-headings/src/index.js27
-rw-r--r--packages/gitbook/package.json2
-rw-r--r--packages/gitbook/src/constants/defaultPlugins.js2
7 files changed, 100 insertions, 2 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
+});
diff --git a/packages/gitbook/package.json b/packages/gitbook/package.json
index 12ca0ac..1b6c0ef 100644
--- a/packages/gitbook/package.json
+++ b/packages/gitbook/package.json
@@ -24,7 +24,7 @@
"gitbook-asciidoc": "1.2.2",
"gitbook-core": "*",
"gitbook-markdown": "1.3.2",
- "gitbook-plugin-fontsettings": "2.0.0",
+ "gitbook-plugin-headings": "1.0.0",
"gitbook-plugin-highlight": "2.0.2",
"gitbook-plugin-livereload": "0.0.1",
"gitbook-plugin-lunr": "1.2.0",
diff --git a/packages/gitbook/src/constants/defaultPlugins.js b/packages/gitbook/src/constants/defaultPlugins.js
index fefb792..f9ddb25 100644
--- a/packages/gitbook/src/constants/defaultPlugins.js
+++ b/packages/gitbook/src/constants/defaultPlugins.js
@@ -25,6 +25,6 @@ module.exports = Immutable.List([
'lunr',
'sharing',
'hints',
- 'fontsettings',
+ 'headings',
'theme-default'
]).map(createFromDependency);