Skip to content

Commit

Permalink
Update README (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
toshimaru committed Apr 17, 2016
1 parent 2ccfc93 commit b7e98cb
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -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
<a id="heading11" class="anchor" href="#heading1-1" aria-hidden="true">
<span class="octicon octicon-link"></span>
</a>
```
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
<a id="heading11" class="anchor" href="#heading1-1" aria-hidden="true">
<span class="octicon octicon-link"></span>
</a>
```

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

Expand Down

0 comments on commit b7e98cb

Please sign in to comment.