Conditionally check for TOC #34
-
Public Repo https://github.com/brooklynrail/brooklynrail-handbook/ Description I would like to be able to wrap the TOC is some markup.
but I am having a hard time figuring out how to conditionally check to see if there is a TOC, or if there are headings on the page. The problem is that the TOC Do you mind pointing out where I would conditionally check for the TOC in the file? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Untested code but you'd want to use the following logic:
{% capture page_toc %}
{% include toc.html html=content %}
{% endcapture %}
{% assign page_toc = page_toc | strip %}
{% if page_toc != "" %}
<div class="toc">
<h2>On this page</h2>
{{ page_toc }}
</div>
{% endif %} |
Beta Was this translation helpful? Give feedback.
-
Thanks. I’ll give that a try |
Beta Was this translation helpful? Give feedback.
Untested code but you'd want to use the following logic:
<div>
and use the TOC that was captured