Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is unclear what extra.top does #18

Open
jshook opened this issue Nov 10, 2021 · 1 comment
Open

It is unclear what extra.top does #18

jshook opened this issue Nov 10, 2021 · 1 comment

Comments

@jshook
Copy link

jshook commented Nov 10, 2021

I read the theme source for this but it was still a bit abstract. It would be nice to have this documented in the top-level docs in a way that shows what the theme designer intended.

@aaranxu
Copy link
Owner

aaranxu commented Nov 20, 2021

The 'extra.top' option is to set the navigation of the section's pages. Because the default navigation config of the Zola cannot find the previous or the next page in the nested section, the 'extra.top' is added to mark the page is the super page that has no parent pages.

You can read the related code in the file templates/macros/docs-navigation.html

{% macro docs_navigation(page, current_section) %}
<div class="docs-navigation d-flex justify-content-between">
  {# 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 %}
  <a href="{{ page.lighter.permalink }}">
    <div class="card my-1">
      <div class="card-body py-2">
        &larr; {{ page.lighter.title }}
      </div>
    </div>
  </a>
  {% 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 %}
        <a href="{{ last_page.permalink }}">
          <div class="card my-1">
            <div class="card-body py-2">
              &larr; {{ last_page.title }}
            </div>
          </div>
        </a>
      {% endif %}
...
{% endmacro %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants