forked from mmistakes/minimal-mistakes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Toggle table of contents via front matter (mmistakes#1310)
* Add jekyll-toc include * Reduce whitespace generated by comments * Add table of contents include to `single` layout * Replace `toc` include with jekyll-toc enabled YAML Front Matter * Update README * Update table of contents documentation - Revise `toc` helper include to mention that it will be deprecated in the next major version. - Add documentation to `single` layout explaining how to enable table of contents on those pages. * Update CHANGELOG and history * Update LICENSE Close mmistakes#1222
- Loading branch information
Showing
29 changed files
with
332 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ Minimal Mistakes is a flexible two-column Jekyll theme. Perfect for hosting your | |
- Several responsive layout options (single, archive index, splash, and paginated home page). | ||
- Optimized for search engines with support for [Twitter Cards](https://dev.twitter.com/cards/overview) and [Open Graph](http://ogp.me/) data | ||
- Optional [header images](https://mmistakes.github.io/minimal-mistakes/docs/layouts/#headers), [custom sidebars](https://mmistakes.github.io/minimal-mistakes/docs/layouts/#sidebars), [table of contents](https://mmistakes.github.io/minimal-mistakes/docs/helpers/#table-of-contents), [galleries](https://mmistakes.github.io/minimal-mistakes/docs/helpers/#gallery), related posts, [breadcrumb links](https://mmistakes.github.io/minimal-mistakes/docs/configuration/#breadcrumb-navigation-beta), [navigation lists](https://mmistakes.github.io/minimal-mistakes/docs/helpers/#navigation-list), and more. | ||
- Commenting support (powered by [Disqus](https://disqus.com/), [Facebook](https://developers.facebook.com/docs/plugins/comments), Google+, [Discourse](https://www.discourse.org/), static-based via [Staticman v1](https://staticman.net/), and custom). | ||
- Commenting support (powered by [Disqus](https://disqus.com/), [Facebook](https://developers.facebook.com/docs/plugins/comments), Google+, [Discourse](https://www.discourse.org/), static-based via [Staticman v1 and v2](https://staticman.net/), and custom). | ||
- [Google Analytics](https://www.google.com/analytics/) support. | ||
- UI localized text in English (default), Brazilian Portuguese (Português brasileiro), Chinese, Danish, Dutch, French (Français), German (Deutsch), Greek, Indonesian, Italian (Italiano), Korean, Nepali (Nepalese), Polish, Russian, Spanish (Español), Swedish, Turkish (Türkçe), and Vietnamese. | ||
|
||
|
@@ -206,4 +206,8 @@ GreedyNav.js is distributed under the terms of the [MIT License](http://opensour | |
|
||
Minimal Mistakes incorporates [Jekyll Group-By-Array](https://github.com/mushishi78/jekyll-group-by-array), | ||
Copyright (c) 2015 Max White <[email protected]>. | ||
Jekyll Group-By-Array is distributed under the terms of the [MIT License](http://opensource.org/licenses/MIT). | ||
Jekyll Group-By-Array is distributed under the terms of the [MIT License](http://opensource.org/licenses/MIT). | ||
|
||
Minimal Mistakes incorporates [@allejo's Pure Liquid Jekyll Table of Contents](https://allejo.io/blog/a-jekyll-toc-in-liquid-only/), | ||
Copyright (c) 2017 Vladimir Jimenez. | ||
Pure Liquid Jekyll Table of Contents is distributed under the terms of the [MIT License](http://opensource.org/licenses/MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{% capture tocWorkspace %} | ||
{%- comment -%} | ||
"...like all things liquid - where there's a will, and ~36 hours to spare, there's usually a/some way" ~jaybe | ||
|
||
Usage: | ||
{% include toc.html html=content sanitize=true class="inline_toc" id="my_toc" h_min=2 h_max=3 %} | ||
|
||
Parameters: | ||
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll | ||
|
||
Optional Parameters: | ||
* sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC | ||
* class (string) : '' - a CSS class assigned to the TOC | ||
* id (string) : '' - an ID to assigned to the TOC | ||
* h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored | ||
* h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored | ||
|
||
Output: | ||
An unordered list representing the table of contents of a markdown block. This snippet will only generate the table of contents and will NOT output the markdown given to it | ||
{%- endcomment -%} | ||
|
||
{% capture my_toc %}{% endcapture %} | ||
{% assign minHeader = include.h_min | default: 1 %} | ||
{% assign maxHeader = include.h_max | default: 6 %} | ||
{% assign nodes = include.html | split: '<h' %} | ||
{% assign firstHeader = true %} | ||
|
||
{% for node in nodes %} | ||
{% if node == "" %} | ||
{% continue %} | ||
{% endif %} | ||
|
||
{% assign headerLevel = node | replace: '"', '' | slice: 0, 1 | times: 1 %} | ||
|
||
{% if headerLevel < minHeader or headerLevel > maxHeader %} | ||
{% continue %} | ||
{% endif %} | ||
|
||
{% if firstHeader %} | ||
{% assign firstHeader = false %} | ||
{% assign minHeader = headerLevel %} | ||
{% endif %} | ||
|
||
{% assign indentAmount = headerLevel | minus: minHeader | add: 1 %} | ||
{% assign _workspace = node | split: '</h' %} | ||
|
||
{% assign _idWorkspace = _workspace[0] | split: '"' %} | ||
{% assign html_id = _idWorkspace[1] %} | ||
|
||
{% capture _hAttrToStrip %}{{ headerLevel }} id="{{ html_id }}">{% endcapture %} | ||
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %} | ||
|
||
{% assign space = '' %} | ||
{% for i in (1..indentAmount) %} | ||
{% assign space = space | prepend: ' ' %} | ||
{% endfor %} | ||
|
||
{% capture my_toc %}{{ my_toc }} | ||
{{ space }}- [{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}](#{{ html_id }}){% endcapture %} | ||
|
||
{% endfor %} | ||
|
||
{% if include.class %} | ||
{% capture my_toc %}{:.{{ include.class }}} | ||
{{ my_toc | lstrip }}{% endcapture %} | ||
{% endif %} | ||
|
||
{% if include.id %} | ||
{% capture my_toc %}{: #{{ include.id }}} | ||
{{ my_toc | lstrip }}{% endcapture %} | ||
{% endif %} | ||
{% endcapture %}{% assign tocWorkspace = '' %} | ||
{{ my_toc | markdownify }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
title: "License" | ||
permalink: /docs/license/ | ||
excerpt: "License for Minimal Mistakes Jekyll Theme." | ||
last_modified_at: 2017-10-16T15:51:24-04:00 | ||
last_modified_at: 2017-10-20T14:44:38-04:00 | ||
--- | ||
|
||
The MIT License (MIT) | ||
|
@@ -63,4 +63,8 @@ GreedyNav.js is distributed under the terms of the [MIT License](http://opensour | |
|
||
Minimal Mistakes incorporates [Jekyll Group-By-Array](https://github.com/mushishi78/jekyll-group-by-array), | ||
Copyright (c) 2015 Max White <[email protected]>. | ||
Jekyll Group-By-Array is distributed under the terms of the [MIT License](http://opensource.org/licenses/MIT). | ||
Jekyll Group-By-Array is distributed under the terms of the [MIT License](http://opensource.org/licenses/MIT). | ||
|
||
Minimal Mistakes incorporates [@allejo's Pure Liquid Jekyll Table of Contents](https://allejo.io/blog/a-jekyll-toc-in-liquid-only/), | ||
Copyright (c) 2017 Vladimir Jimenez. | ||
Pure Liquid Jekyll Table of Contents is distributed under the terms of the [MIT License](http://opensource.org/licenses/MIT). |
Oops, something went wrong.