Merge pull request #14 from LASSAT-YU/master
Allow user to control how many headings are needed before it shows in the nav
This commit is contained in:
commit
76ff110bad
2 changed files with 17 additions and 4 deletions
|
@ -19,3 +19,6 @@ easydocs_logo_always_clickable = false
|
|||
# - Also requries the base URL to be set to the local folder where the site is stored eg. base_url = /home/user/mysite/public/
|
||||
# - This is not portable and only works with a specific local folder
|
||||
easydocs_uglyurls = false
|
||||
|
||||
# Minimum number of headings needed on a page before the headings show in the navigation on the left. Defaults to 5.
|
||||
easydocs_heading_threshold = 5
|
|
@ -30,7 +30,7 @@
|
|||
{% endif -%}
|
||||
<main>
|
||||
{# Create variable to allow appending index.html at end of links if set in config #}
|
||||
{% if not config.extra.easydocs_uglyurls or config.mode == "Serve" -%}
|
||||
{% if not config.extra.easydocs_uglyurls or config.mode == "serve" -%}
|
||||
{% set _ugly_url = "" -%}
|
||||
{% else %}
|
||||
{% set _ugly_url = "index.html" -%}
|
||||
|
@ -81,6 +81,7 @@
|
|||
|
||||
{% if current_path == page.path -%}
|
||||
|
||||
{# Count number of headers on page #}
|
||||
{% set_global header_count = 0 -%}
|
||||
{% for h2 in page.toc -%}
|
||||
{% set_global header_count = header_count + 1 -%}
|
||||
|
@ -92,11 +93,20 @@
|
|||
{% endfor -%}
|
||||
{% endfor -%}
|
||||
|
||||
{% if header_count > 4 -%}
|
||||
{# Output headers if above threshold #}
|
||||
{% if not config.extra.easydocs_heading_threshold -%}
|
||||
{# Undefined or 0 unable to find a way to differnciate between 0 and undefined.
|
||||
1 is already including any headings so is not 0 not needed #}
|
||||
{% set _threshold = 5 -%}
|
||||
{% else %}
|
||||
{% set _threshold = config.extra.easydocs_heading_threshold -%}
|
||||
{% endif -%}
|
||||
|
||||
{% if header_count >= _threshold -%}
|
||||
<ul id="toc">
|
||||
{% for h2 in page.toc -%}
|
||||
<li><a href="
|
||||
{{ h2.permalink | safe }}{{ _ugly_url }}">{{ h2.title }}</a>
|
||||
{{ h2.permalink | safe }}">{{ h2.title }}</a>
|
||||
{% if h2.children -%}
|
||||
<ul>
|
||||
{% for h3 in h2.children -%}
|
||||
|
|
Loading…
Reference in a new issue