Created
January 6, 2017 20:08
-
-
Save Phlow/bde855633b01c41c51715f0a108d987f to your computer and use it in GitHub Desktop.
This is a nested liquid loop for Jekyll to iterate through YAML data with a depth of three levels. The example loops through a potential table of contents of a book.
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
{% comment %} | |
# | |
# This is a nested liquid loop for Jekyll to iterate through YAML data with | |
# a depth of three levels. The example loops through a potential table of | |
# contents of a book. | |
# | |
# This is the example YAML content' | |
- chapters: 'Einführung' | |
sub_chapters: | |
- title: 'Einführung in Jekyll' | |
- chapters: 'Installation' | |
sub_chapters: | |
- title: Sub_Subchapter | |
sub_sub_chapters: | |
- title : 'Mac Installation' | |
url : 'mac-install.adoc' | |
- title : 'Window Installation' | |
url : 'window-install.adoc' | |
- title : 'Linux Installation' | |
url : 'linux-install.adoc' | |
- title : 'Mac Installation' | |
url : 'mac-install.adoc' | |
- title : 'Window Installation' | |
url : 'window-install.adoc' | |
- title : 'Linux Installation' | |
url : 'linux-install.adoc' | |
- chapters: 'Aufbau einer Jekyll-Website' | |
sub_chapters: | |
- title : '_config.yml' | |
url : 'config.adoc' | |
- title : 'Variablen' | |
url : 'variablen.adoc' | |
- title : 'Programmieren mit Liquid' | |
url : 'liquid.adoc' | |
- title : 'Front Matter & YAML' | |
url : 'front-matter.adoc' | |
{% endcomment %} | |
{% for entry in site.data.toc_jekyll %} | |
<h2>{{ entry.chapters }}</h2> | |
{% for subchapter in entry.sub_chapters %} | |
{% if forloop.first %}<ul>{% endif %} | |
<li><h3><a href="{{ subchapter.url }}">{{ subchapter.title }}</a></h3></li> | |
{% for subsubchapter in subchapter.sub_sub_chapters %} | |
{% if forloop.first %}<ul>{% endif %} | |
<li><h4><a href="{{ subchapter.url }}">{{ subchapter.title }}</a></h4></li> | |
{% if forloop.last %}</ul>{% endif %} | |
{% endfor %} | |
{% if forloop.last %}</ul>{% endif %} | |
{% endfor %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Phlow I tried something similar at https://gist.github.com/inetbiz/4f6b24492a37ca0aceddd826b14f875e
I did not work! =(