diff --git a/README.md b/README.md index f047568..772085b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ -# GitBook Plugin: InTopic TOC +# GitBook plugin: InTopic TOC -This GitBook Plugin adds an inline table of contents (TOC) to each page based on configurable selectors. Inline TOC can be enabled or disabled by default or on individual pages. TOC is placed on the right side and moves to top for smaller devices automatically. +![Build Status](https://api.travis-ci.org/zanfab/gitbook-plugin-intopic-toc.svg) +[![npm version](https://img.shields.io/npm/v/gitbook-plugin-intopic-toc/latest.svg)](https://www.npmjs.com/package/gitbook-plugin-intopic-toc) + +This GitBook plugin adds an inline table of contents (TOC) to each page based on configurable selectors. Inline TOC can be enabled or disabled by default or on individual pages. TOC is placed on the right side and moves to top for smaller devices automatically. Inline TOC stays at the top of the page when scrolling using a sticky effect. Current position is highlighted by a scrollspy effect. ![Inline TOC in desktop and mobile mode](https://user-images.githubusercontent.com/44210522/50728477-ab322680-112a-11e9-92da-4de20e17758d.png) +Plugin uses [gumshoe](https://github.com/cferdinandi/gumshoe) and [anchorjs](https://github.com/bryanbraun/anchorjs) to implement functionality. + ## Installation ### Step #1 - Update book.json file @@ -85,12 +90,11 @@ For basic usage, the only thing you have to do is install the plugin. For advanc } ``` -* selector : Selector used to find elements to put anchors on. - * Default: .markdown-section h2 -* visible: Defines whether to show the navigation on every page. - * Default: true. -* label: Label which is used as heading for the navigation. Could be a single string or an object for multilingual setups. - * Default: In this article +| Property | Description | Default value | +| -------- | ------------------------------------------------------------ | -------------------- | +| selector | Selector used to find elements to put anchors on | .markdown-section h2 | +| visible | Defines whether to show the navigation on every page | true | +| label | Label which is used as heading for the navigation. Could be a single string or an object for multilingual setups | In this article | If `visible` parameter set to true and you want to hide the TOC on a single page, add the front matter item `isTocVisible: false` to the top of the Markdown file like this: @@ -110,4 +114,7 @@ The specific front matter `isTocVisible` overrides the `visible` parameter from If inline TOC does not look as expected, check if your `book.json` is valid according to this documentation. ## Changelog + +01/07/2019 - Used [gumshoe scrollspy script](https://github.com/cferdinandi/gumshoe) for a better experience + 01/05/2019 - Initial Release diff --git a/book/gumshoe.min.js b/book/gumshoe.min.js new file mode 100644 index 0000000..d167755 --- /dev/null +++ b/book/gumshoe.min.js @@ -0,0 +1,2 @@ +/*! gumshoejs v3.5.1 | (c) 2018 Chris Ferdinandi | MIT License | http://github.com/cferdinandi/gumshoe */ +!function(e,t){"function"==typeof define&&define.amd?define([],t(e)):"object"==typeof exports?module.exports=t(e):e.gumshoe=t(e)}("undefined"!=typeof global?global:this.window||this.global,function(c){"use strict";var i,t,s,n,o,r,a={},l=[],u={selector:"[data-gumshoe] a",selectorHeader:"[data-gumshoe-header]",container:c,offset:0,activeClass:"active",scrollDelay:!1,callback:function(){}},d=function(e,t,n){if("[object Object]"===Object.prototype.toString.call(e))for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(n,e[o],o,e);else for(var r=0,a=e.length;rt.distance?-1:e.distance=s&&g(l[0].target))return p(l[0]),l[0];var n=l[l.length-1];if(t