lukasgeiter / mkdocs-awesome-pages-plugin

An MkDocs plugin that simplifies configuring page titles and their order
MIT License
452 stars 35 forks source link

Hide pages but still show left navigation? #94

Closed changbowen closed 7 months ago

changbowen commented 7 months ago

Hi! I tried hide: true and ... | regex=[^xxxx] and they hide both the tab on the top and the left navigation list. Any idea how to only hide the tabs but still show the left navigation list so the hidden content is still usable (e.g. when accessed via direct link)?

I'm trying to do a "private" section that is behind authentication so kind of need a functional navigation...

When not hidden:

When hidden (opened via link):

kamilkrzyskow commented 7 months ago

If I understood correctly you wish to remove the Private from the tabs and keep the left navigation on the Private page. Also it can't be just hidden (with CSS), but completely removed out of the rendered HTML source code. To achieve that I think you'd have to override either the partials/tabs.html or partials/tabs-item.html templates of the Material for MkDocs theme. https://squidfunk.github.io/mkdocs-material/customization/#overriding-partials This part of the tabs.html file should do it:

    <ul class="md-tabs__list">
      {% for nav_item in nav %}
        {{ item.render(nav_item) }}
      {% endfor %}
    </ul>

I believe you should be able to extract something out of the nav_item here and use a conditional and avoid adding the Preview to the tabs.

changbowen commented 7 months ago

That actually works.. I was able to hide Private tab using something like these overriding tabs.html:

{% for nav_item in nav %}
  {% if nav_item and nav_item.title != 'Private' %}
    {{ item.render(nav_item) }}
  {% endif %}
{% endfor %}

But in the end I went for a separate site under /private for more flexible content arrangement. Thanks for the help!