From b7e98cb953dae0b8a16a6460bcec2e621c81d50a Mon Sep 17 00:00:00 2001 From: toshi Date: Sun, 17 Apr 2016 20:14:13 +0900 Subject: [PATCH] Update README (#13) --- README.md | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index ffd0642..cbaa1c6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Code Climate](https://codeclimate.com/github/toshimaru/jekyll-toc/badges/gpa.svg)](https://codeclimate.com/github/toshimaru/jekyll-toc) [![Test Coverage](https://codeclimate.com/github/toshimaru/jekyll-toc/badges/coverage.svg)](https://codeclimate.com/github/toshimaru/jekyll-toc/coverage) -# Usage +# Installation Add jekyll-toc plugin in your site's `Gemfile`. @@ -31,39 +31,47 @@ toc: true --- ``` +# Usage + There are three Liquid filters available now, which all should be applied to some HTML content, e.g. the Liquid variable `content` available in Jekyll's templates. -1. `toc_only` - Generates the TOC itself as described [below](#generated-table-of-contents-html). - Mostly useful in cases where the TOC should _not_ be placed immediately - above the content but at some other place of the page, i.e. an aside. +## Basic Usage + +### `toc` filter + +Add `toc` filter to your site's `{{ content }}` (e.g. `_layouts/post.html`). + +``` +{{ content | toc }} +``` + +This filter places the TOC directly above the content. -2. `inject_anchors` - Injects HTML anchors into the content without actually outputing the - TOC itself. - They are of the form: +## Advanced Usage - ```html - - ``` +If you'd like separated TOC and content, you can use `toc_only` and `inject_anchors` filters. - This is only useful when the TOC itself should be placed at some other - location with the `toc_only` filter. +### `toc_only` filter -3. `toc` - This is the concatenation of the two above, where the TOC is placed - directly above the content. +Generates the TOC itself as described [below](#generated-table-of-contents-html). +Mostly useful in cases where the TOC should _not_ be placed immediately +above the content but at some other place of the page, i.e. an aside. - Add `toc` filter to your site's `{{ content }}` (e.g. `_layouts/post.html`). +### `inject_anchors` filter - ``` - {{ content | toc }} - ``` +Injects HTML anchors into the content without actually outputing the +TOC itself. They are of the form: + +```html + +``` +This is only useful when the TOC itself should be placed at some other +location with the `toc_only` filter. ## Generated Table of Contents HTML