Skip to content

Commit f139f22

Browse files
committed
Try another method to get the toc and display it on the side bar
1 parent 76ddcb5 commit f139f22

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/_layouts/default.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ <h2>Quick Navigation</h2>
2121
<ul> <!-- Add this UL here -->
2222
{% assign headings = site.pages | where: "path", item.url | first %}
2323
{% if headings %}
24-
{% for heading in headings.content | split: '## ' %}
25-
{% if heading != '' %}
26-
{% assign parts = heading | split: '\n' %}
27-
<li><a href="#{{ parts[0] | slugify }}">{{ parts[0] }}</a></li>
24+
{% assign content = headings.content %}
25+
{% assign lines = content | split: '\n' %}
26+
{% for line in lines %}
27+
{% if line contains '## ' %}
28+
<li><a href="#{{ line | split: '## ' | last | slugify }}">{{ line | split: '## ' | last }}</a></li>
2829
{% endif %}
2930
{% endfor %}
3031
{% endif %}

0 commit comments

Comments
 (0)