All Projects → Sommerregen → grav-plugin-toc

Sommerregen / grav-plugin-toc

Licence: other
This plugin automagically generates a (minified) Table of Contents based on special markers in the document and adds it into the resulting HTML document.

Programming Languages

PHP
23972 projects - #3 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to grav-plugin-toc

grav-plugin-form
Grav Form Plugin
Stars: ✭ 48 (+300%)
Mutual labels:  grav, grav-plugin
grav-plugin-simplesearch
Grav SimpleSearch Plugin
Stars: ✭ 40 (+233.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-taxonomylist
Grav TaxonomyList Plugin
Stars: ✭ 19 (+58.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-data-manager
Grav Data Manager Plugin
Stars: ✭ 28 (+133.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-themer
This plugin enables you use different themes on one site individual set per page or collection.
Stars: ✭ 16 (+33.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-readingtime
Grav ReadingTime Plugin
Stars: ✭ 19 (+58.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-blackhole
The static site generator for Grav CMS
Stars: ✭ 152 (+1166.67%)
Mutual labels:  grav, grav-plugin
grav-plugin-youtube
Grav YouTube Plugin
Stars: ✭ 21 (+75%)
Mutual labels:  grav, grav-plugin
grav-plugin-jscomments
JSComments is a Grav (http://github.com/getgrav/grav) plugin which allows to integrate comments into individual pages from Discourse / Disqus / Facebook / Google+ / HyperComments / IntenseDebate / Isso, and Muut comment systems.
Stars: ✭ 28 (+133.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-maintenance
Grav Maintenance Plugin
Stars: ✭ 12 (+0%)
Mutual labels:  grav, grav-plugin
grav-plugin-markdown-notices
Grav Markdown Notices Plugin
Stars: ✭ 31 (+158.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-featherlight
Grav Featherlight Plugin
Stars: ✭ 29 (+141.67%)
Mutual labels:  grav, grav-plugin
grav-plugin-shortcode-ui
Grav Shortcode UI Plugin
Stars: ✭ 45 (+275%)
Mutual labels:  grav, grav-plugin
grav-plugin-lightslider
Grav LightSlider Plugin
Stars: ✭ 14 (+16.67%)
Mutual labels:  grav, grav-plugin
grav-plugin-sitemap
Grav Sitemap Plugin
Stars: ✭ 34 (+183.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-login
Grav Login Plugin
Stars: ✭ 40 (+233.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-devtools
Grav Devtools Plugin
Stars: ✭ 36 (+200%)
Mutual labels:  grav, grav-plugin
grav-plugin-instagram
Instagram is a simple plugin that includes Instagram feed to your Grav website.
Stars: ✭ 13 (+8.33%)
Mutual labels:  grav, grav-plugin
grav-plugin-shortcode-core
Grav Shortcode Core Plugin
Stars: ✭ 42 (+250%)
Mutual labels:  grav, grav-plugin
grav-plugin-proposal
Sales Proposal Plugin for Grav
Stars: ✭ 16 (+33.33%)
Mutual labels:  grav, grav-plugin

Grav Toc Plugin

Release Issues Dual license Flattr PayPal

This plugin automagically generates a (minified) Table of Contents based on special markers in the document and adds it into the resulting HTML document.

Table of Contents:

About

Toc is a plugin for Grav used to generate Table of Contents from a Markdown document based on special markers. The markers are [TOC] and [MINITOC], where the latter can be used for a (minified) Table of Contents to give an overview of the current content of the section. By default, the Table of Contents links to the contents (anchorlinks) and adds visible permanent links (permalinks) to all headers. Further, all headers will automatically have unique id attributes generated based upon the text of the header. See how it looks like:

Screenshot Toc Plugin

Installation and Updates

Installing or updating the Toc plugin can be done in one of two ways. Using the GPM (Grav Package Manager) installation update method (i.e. bin/gpm install toc) or manual install by downloading this plugin and extracting all plugin files to

user/plugins/toc

For more informations, please check the Installation and update guide.

Usage

The Toc plugin comes with some sensible default configuration, that are pretty self explanatory:

Config Defaults

# Global plugin configurations

enabled: true                # Set to false to disable this plugin completely
active: true                 # Option to (de-)activate this plugin on a page
built_in_css: true           # Use built-in CSS of the plugin

# Global and page specific configurations

title: true                  # Title to insert in the table of contents
anchorlink: true             # Set to true to cause all headers to link to themselves
permalink: true              # Set to true to generate permanent links at the beginning of each header

placement: "left"            # Either "left" or "right"
visible: "hover"             # Active on "hover" or "always" visible
icon: "#"                    # Default link or a specific character like: #, ¶, ❡, and §
class: []                    # Adds the provided classes to the anchor HTML

baselevel: 1                 # Base level for headings
headinglevel: 6              # Maximum heading level to show in TOC

slug:                        # Slug generation
  truncate: true             # Truncate headings for slug generation
  granularity: "words"       # Granularity of slug generation (based on "words" or "character")
  length: 32                 # Slug string length
  break: "-"                 # The break delimiter to divide the slug into pieces of words.
  pad: "..."                 # Added to the end of the truncated slug

If you need to change any value, then the best process is to copy the toc.yaml file into your users/config/plugins/ folder (create it if it doesn't exist), and then modify there. This will override the default settings.

If you want to alter the settings for one or a few pages only, you can do so by adding page specific configurations into your page headers, e.g.

toc:
  permalink: false

to disable permalinks or

toc: false

to disable the Toc plugin just for this page.

Notice: The PHP iconv module is required in order to properly convert UTF-8 titles into human readable slugs.

Twig Filter

Toc provides a Twig filter to render a table of contents for any text, which uses the markers [TOC] or [MINITOC]. To do that, place the following line of code in the theme file you wish to add the Toc plugin for:

{{ page.content|toc }}

You can pass arguments to the plugin filter, namely the same arguments as available in the toc.yaml file. For example

{{ page.content|toc({'permalink': false, 'baselevel': 2}) }}

would disable permalinks and creates a table of contents only for second-level headings and higher.

CSS Stylesheet Override

Something you might want to do is to override the look and feel of the table of contents, and with Grav it is super easy.

Copy the stylesheet assets/css/toc.css into the css folder of your custom theme, modify it and add it to the list of CSS files.

themes/custom-theme/css/toc.css

After that set the built_in_css option of the Toc plugin to false. That's it.

Contributing

You can contribute at any time! Before opening any issue, please search for existing issues and review the guidelines for contributing.

After that please note:

  • If you find a bug, would like to make a feature request or suggest an improvement, please open a new issue. If you have any interesting ideas for additions to the syntax please do suggest them as well!
  • Feature requests are more likely to get attention if you include a clearly described use case.
  • If you wish to submit a pull request, please make again sure that your request match the guidelines for contributing and that you keep track of adding unit tests for any new or changed functionality.

Support and donations

If you like my project, feel free to support me via Flattr or by sending me some bitcoins to 1HQdy5aBzNKNvqspiLvcmzigCq7doGfLM4.

Thanks!

License

Copyright (c) 2015-2017 Benjamin Regler. See also the list of contributors who participated in this project.

Dual-licensed for use under the terms of the MIT or GPLv3 licenses.

GNU license - Some rights reserved

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].