ntno / mkdocs-terminal

monospace theme for MkDocs
https://ntno.github.io/mkdocs-terminal/
MIT License
96 stars 3 forks source link

Show side navigation with only one top-level document #137

Closed animatabledotco closed 9 months ago

animatabledotco commented 9 months ago

I would like to use a navigation structure that uses a single top-level document and several sub documents, like this:

nav:
    - User Guide:
          - Index: "index.md"
          - How it works: "how-it-works"
          - Attach Points: "attach points"
          - Convert To Mask: "convert-to-mask"
          - Tips & FAQ: "tips-and-faq"

But none of this shows up in the side navigation. Unless I add a second top-level document like this:

nav:
    - User Guide:
          - Index: "index.md"
          - How it works: "how-it-works"
          - Attach Points: "attach points"
          - Convert To Mask: "convert-to-mask"
          - Tips & FAQ: "tips-and-faq"
    - Unwanted Page:
          - Index: "index.md"

Is there a way to show the top and second level documents, even when there is only one top-level. Other themes seem to allow it. Thanks

ntno commented 9 months ago

hi @animatabledotco i was able to recreate this issue and i agree it is strange. thank you for reporting.
i will have to look into it to determine a root cause.
in the meantime, i see that you closed the issue. were you able to find a work-around? if so, can you please let me know what you did to fix it? thanks!

stevekirby commented 9 months ago

hi @animatabledotco i was able to recreate this issue and i agree it is strange. thank you for reporting. i will have to look into it to determine a root cause. in the meantime, i see that you closed the issue. were you able to find a work-around? if so, can you please let me know what you did to fix it? thanks!

Hey there, thanks for replying. I found that in partials > side-nav > side-nav.html there is {% if nav|length>1 %} so I just removed that (and the corresponding {% endif %}). I was going to post here but assumed it was all by design and customizing like this was something I should have grasped sooner.

ntno commented 9 months ago

hi @stevekirby

awesome! yes that makes sense. i believe i put the length conditional in there because i thought it would be silly to display the home page in the sidebar if that page was the only item in the navigation. it seemed redundant because the site_name (displayed with a > at the top left) already links to the home page. however i did not consider your use case where there is one top level section and no sibling pages.

your comment has inspired me to re-think the way the side navigation is rendered though. i am working on an update which will allow deeper nesting in the side bar. when i make this change i will also get rid of the length>1 conditional.

5.0.0 release preview

nav with single page

nav:
    - Install: 'install.md'

single-page

nav with one section which has an index page

nav:
    - Tile Grid:
      - Index: 'tile-grid/index.md'
      - Tile Reference: 'tile-grid/tile.md'
      - Grid Reference: 'tile-grid/grid.md'
      - Pluglet Reference: 'tile-grid/pluglet.md'
      - Example: 'tile-grid/examples/example-page.md'
      - Image Only: 'tile-grid/examples/images-only.md'
      - Link Only: 'tile-grid/examples/links-only.md'
      - Override Styling: 'tile-grid/examples/override-styling.md'
      - Inline Example: 'tile-grid/examples/inline.md'

with-index

nav with one section (no index page)

    - Elements:
      - Blockquotes: 'elements/blockquotes.md'
      - Buttons: 'elements/buttons.md'
      - Definitions: 'elements/definitions.md'
      - Figures: 'elements/figure.md'
      - Footnotes: 'elements/footnotes.md'
      - Links: 'elements/links.md'
      - Lists: 'elements/lists.md'
      - Tables: 'elements/table.md'
      - Tooltips: 'elements/tooltips.md'
      - Typography: 'elements/typography.md'

no-index