{# Find lighter navigation. There are three types: #}
{# 1. directly find the lighter if exists, #}
{# 2. find the last page in the previous sibling section, and #}
{# 3. find the last page in the parent section. #}
{% if page.lighter %}
{% elif not page.extra.top %}
{% set index = get_section(path=page.ancestors | reverse | first) %}
{% set parent = get_section(path=index.ancestors | reverse | first)%}
{% set first_subsection = get_section(path=parent.subsections | first) %}
{% if index == first_subsection %}
{% if parent.pages %}
{% set last_page = parent.pages | last %}
{% endif %}
{# no break #}
{% set_global found_current = false %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{# Find heavier navigation. There are also three types: #}
{# 1. directly find the heavier if exists, #}
{# 2. find the first page in the subsection, and #}
{# 3. find the first page in the next sibling section. #}
{% if page.heavier %}