summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/gitbook-plugin-hints/.gitignore31
-rw-r--r--packages/gitbook-plugin-hints/.npmignore2
-rw-r--r--packages/gitbook-plugin-hints/README.md41
-rw-r--r--packages/gitbook-plugin-hints/index.js11
-rw-r--r--packages/gitbook-plugin-hints/package.json29
-rw-r--r--packages/gitbook-plugin-hints/src/index.js40
-rw-r--r--packages/gitbook/package.json3
-rw-r--r--packages/gitbook/src/constants/defaultPlugins.js1
8 files changed, 157 insertions, 1 deletions
diff --git a/packages/gitbook-plugin-hints/.gitignore b/packages/gitbook-plugin-hints/.gitignore
new file mode 100644
index 0000000..7c6f0eb
--- /dev/null
+++ b/packages/gitbook-plugin-hints/.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
diff --git a/packages/gitbook-plugin-hints/.npmignore b/packages/gitbook-plugin-hints/.npmignore
new file mode 100644
index 0000000..7bc36b7
--- /dev/null
+++ b/packages/gitbook-plugin-hints/.npmignore
@@ -0,0 +1,2 @@
+# Publish assets on NPM
+!_assets
diff --git a/packages/gitbook-plugin-hints/README.md b/packages/gitbook-plugin-hints/README.md
new file mode 100644
index 0000000..9952b97
--- /dev/null
+++ b/packages/gitbook-plugin-hints/README.md
@@ -0,0 +1,41 @@
+Styled hint blocks in your docs
+==============
+
+This plugins requires gitbook `>=4.0.0`.
+
+### Install
+
+Add the below to your `book.json` file, then run `gitbook install` :
+
+```json
+{
+ "plugins": ["hints"]
+}
+```
+
+### Usage
+
+You can now provide hints in various ways using the `hint` tag.
+
+```markdown
+{% hint style='info' %}
+Important info: this note needs to be highlighted
+{% endhint %}
+```
+
+##### Styles
+
+Available styles are:
+
+- `info` (default)
+- `tip`
+- `danger`
+- `warning`
+
+##### Custom Icons
+
+```markdown
+{% hint style='info' icon="mail" %}
+Important info: this note needs to be highlighted
+{% endhint %}
+```
diff --git a/packages/gitbook-plugin-hints/index.js b/packages/gitbook-plugin-hints/index.js
new file mode 100644
index 0000000..55efd25
--- /dev/null
+++ b/packages/gitbook-plugin-hints/index.js
@@ -0,0 +1,11 @@
+
+module.exports = {
+ blocks: {
+ hint: ({ kwargs }) => {
+ return {
+ style: kwargs.style || 'info',
+ icon: kwargs.icon
+ };
+ }
+ }
+};
diff --git a/packages/gitbook-plugin-hints/package.json b/packages/gitbook-plugin-hints/package.json
new file mode 100644
index 0000000..bd9f65b
--- /dev/null
+++ b/packages/gitbook-plugin-hints/package.json
@@ -0,0 +1,29 @@
+{
+ "name": "gitbook-plugin-hints",
+ "description": "Defines four types of styled hint blocks: info, danger, tip, working.",
+ "main": "index.js",
+ "browser": "./_assets/theme.js",
+ "version": "2.0.0",
+ "dependencies": {
+ "classnames": "^2.2.5",
+ "gitbook-core": "^0.0.0"
+ },
+ "devDependencies": {
+ "gitbook-plugin": "*"
+ },
+ "engines": {
+ "gitbook": ">=4.0.0"
+ },
+ "scripts": {
+ "build-js": "gitbook-plugin build ./src/index.js ./_assets/theme.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-hints/src/index.js b/packages/gitbook-plugin-hints/src/index.js
new file mode 100644
index 0000000..0d1c152
--- /dev/null
+++ b/packages/gitbook-plugin-hints/src/index.js
@@ -0,0 +1,40 @@
+const classNames = require('classnames');
+const GitBook = require('gitbook-core');
+const { React } = GitBook;
+
+const STYLE_TO_ICON = {
+ info: 'info',
+ tip: 'question',
+ danger: 'exclamation-circle',
+ warning: 'exclamation-triangle'
+};
+
+const HintAlert = React.createClass({
+ propTypes: {
+ icon: React.PropTypes.string,
+ style: React.PropTypes.string,
+ children: React.PropTypes.node
+ },
+
+ render() {
+ const { children, style, icon } = this.props;
+ const className = classNames('HintAlert', 'alert', `alert-${style}`);
+
+ return (
+ <div className={className}>
+ <div className="HintAlert/Icon">
+ <GitBook.Icon id={icon || STYLE_TO_ICON[style]} />
+ </div>
+ <div className="HintAlert/Content">
+ {children}
+ </div>
+ </div>
+ );
+ }
+});
+
+module.exports = GitBook.createPlugin({
+ init: (dispatch, getState) => {
+ dispatch(GitBook.registerComponent(HintAlert, { role: 'block:hint' }));
+ }
+});
diff --git a/packages/gitbook/package.json b/packages/gitbook/package.json
index 8b6551e..c3e9ce9 100644
--- a/packages/gitbook/package.json
+++ b/packages/gitbook/package.json
@@ -1,6 +1,6 @@
{
"name": "gitbook",
- "version": "3.2.0",
+ "version": "4.0.0",
"homepage": "https://www.gitbook.com",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
@@ -31,6 +31,7 @@
"gitbook-plugin-search": "2.2.1",
"gitbook-plugin-sharing": "1.0.2",
"gitbook-plugin-theme-default": "1.0.5",
+ "gitbook-plugin-hints": "2.0.0",
"github-slugid": "1.0.1",
"graceful-fs": "4.1.4",
"i18n-t": "1.0.1",
diff --git a/packages/gitbook/src/constants/defaultPlugins.js b/packages/gitbook/src/constants/defaultPlugins.js
index cd1c0c8..fefb792 100644
--- a/packages/gitbook/src/constants/defaultPlugins.js
+++ b/packages/gitbook/src/constants/defaultPlugins.js
@@ -24,6 +24,7 @@ module.exports = Immutable.List([
'search',
'lunr',
'sharing',
+ 'hints',
'fontsettings',
'theme-default'
]).map(createFromDependency);