Skip to content

Commit 0d63979

Browse files
author
Misty Stanley-Jones
committed
Make 'toc_min: 1' work
1 parent a09e279 commit 0d63979

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

_includes/toc_pure_liquid.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
{% assign html_id = _idWorkspace[1] %}
4646

4747
{% capture _hAttrToStrip %}{{ headerLevel }} id="{{ html_id }}">{% endcapture %}
48-
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' %}
48+
{% assign header = _workspace[0] | replace: _hAttrToStrip, '' | remove_first: "1>" %}
4949

5050
{% assign space = '' %}
5151
{% for i in (1..indentAmount) %}

_layouts/docs.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,19 @@
289289
{% assign my_min = page.toc_min | default: site.toc_min | default: 2 %}
290290
{% assign my_max = page.toc_max | default: site.toc_max | default: 3 %}
291291
{% assign my_name = page.url | default: "unnamed" %}
292-
<div id="side-toc"><div id="side-toc-title">On this page:</div><div id="side-toc-contents">{% include toc_pure_liquid.html html=content sanitize=true class="inline_toc" id="my_toc" toc_min=my_min toc_max=my_max page_name=my_name %}</div></div>
292+
{% if my_min < 2 %}
293+
{% comment %}
294+
the 'content' variable doesn't include the <h1> by default
295+
so if we request the h1 heading to be in the in-page TOC,
296+
append it to the content before we pass it to the TOC generator
297+
{% endcomment %}
298+
{% assign my_content = "<h1>" | append: page.title | append: "</h1>" | append: content %}
299+
{% else %}
300+
{% assign my_content = content %}
301+
{% endif %}
302+
<div id="side-toc"><div id="side-toc-title">On this page:</div><div id="side-toc-contents">{% include toc_pure_liquid.html html=my_content sanitize=true class="inline_toc" id="my_toc" toc_min=my_min toc_max=my_max page_name=my_name %}</div></div>
293303
{% endunless %}
304+
<div>{{content}}</div>
294305
</section>
295306
</div>
296307
</div>

0 commit comments

Comments
 (0)