mirror of
https://github.com/zhigang1992/probot.github.io.git
synced 2026-04-24 04:15:48 +08:00
Magic trick to remove title duplication in TOC
This commit is contained in:
@@ -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 %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user