Magic trick to remove title duplication in TOC

This commit is contained in:
Brandon Keepers
2017-08-07 14:42:03 -05:00
parent ddc594db90
commit e466287603
4 changed files with 48 additions and 35 deletions

View File

@@ -7,8 +7,34 @@ layout: default
<div class="container-lg px-3 py-6">
<div class="d-flex flex-row gutter-spacious">
<div id="toc" class="col-3 py-6">
{% capture toc %}{% include toc.md %}{% endcapture %}
{{ toc | markdownify }}
{% for section in site.data.toc %}
<h2 class="alt-h4">{{ section[0] }}</h2>
<ul class="mt-2 mb-4 list-style-none">
{% for item in section[1] %}
<li>
{% if item.url %}
{% assign link = item %}
{% else %}
{% for doc in site.pages %}
{% if doc.path == item %}
{% assign link = doc %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
{% if page.url == link.url %}
{% assign classes = "text-brand-red" %}
{% else %}
{% assign classes = "text-gray-light" %}
{% endif %}
<a class="d-block no-underline py-1 {{classes}}" href="{{ link.url }}">{{ link.title }}</a>
</li>
{% endfor %}
</ul>
{% endfor %}
</div>
<div class="col-9 markdown-body p-6">
{{ content }}
@@ -16,10 +42,12 @@ layout: default
{% for doc in site.pages %}
{% if page.next == doc.path %}
{% assign next = doc %}
{% break %}
{% endif %}
{% if doc.next == page.path %}
{% assign previous = doc %}
{% break %}
{% endif %}
{% endfor %}