GithubHelp home page GithubHelp logo

aleung / gitbook-plugin-page-toc Goto Github PK

View Code? Open in Web Editor NEW
27.0 4.0 13.0 71 KB

Add Table of Contents (TOC) to every page in your GitBook.

License: MIT License

JavaScript 88.38% CSS 11.62%
gitbook-plugin toc-generator

gitbook-plugin-page-toc's Introduction

gitbook-plugin-page-toc

This plugin adds a table of contents (TOC) to each page in your Gitbook. You can set whether the TOC appears on all pages by default, and you can enable or disable the TOC on individual pages to override the default.

Install

Add the plugin to your book.json:

{
  "plugins": [ "page-toc" ],
  "pluginsConfig": {
    "page-toc": {
      "selector": ".markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4",
      "position": "before-first",
      "showByDefault": true
    }
  }
}

Configuration

  • selector : CSS selector to select the elements to put anchors on
    • Default: .markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4, which include headings from level 1 to level 4.
  • position : Position of TOC
    • Allowed values:
      • before-first (default) : Before the first heading
      • top : On top of the page
  • showByDefault: Whether to show the TOC on all pages by default.
    • Default: true.

Use

To show a TOC in one of your pages, either set the showByDefault parameter to true in your book.json, or add the front matter item showToc: true to the top of the Markdown file like this:

---
showToc: true
---
# My interesting page that has a TOC

If you have the showByDefault parameter set to true and you want to hide the TOC on a page, add the front matter item showToc: false to the top of the Markdown file like this:

---
showToc: false
---
# My interesting page that does not have a TOC

The page-specific front matter overrides the showByDefault parameter.

CSS Customization

The TOC elements have class attribute .page-toc. You can override the styles in styles/website.css.

gitbook-plugin-page-toc's People

Contributors

aleung avatar huang-x-h avatar timothymcmackin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gitbook-plugin-page-toc's Issues

Internationalization title.

First of all I want to congratulate the work was very good.

I am writing a booklet in Portuguese, and would like to change the title box where the ToC is displayed. Changing the text to Portuguese.

Add possibility to disable for specific pages

Thanks for this plugin I use in various gitbooks.

A cool capacity would be to allow disabling TOC for specific pages,. It could be with a specific tag like {% notoc %} or with an option in book.json/pluginsConfig/page-toc/"exclude": "page.md,...".

use case is for pages with a lot of titles, so the TOC is too huge to be usable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.