oprypin / mkdocs-literate-nav

MkDocs plugin to specify the navigation in Markdown instead of YAML
https://oprypin.github.io/mkdocs-literate-nav
MIT License
73 stars 8 forks source link

Deeply nested navigation creates bad menus #26

Closed smokedlinq closed 1 year ago

smokedlinq commented 1 year ago

Example:

* [Level1](level1)

In level1 directory the nav md contains:

* Level2
  * Level3
    * Level4
      * [Level4 Item](level3/level4/item.md)
    * [Level3 Item](level3/item.md)

What I see when rendered is that Level3 item ends up being a link to Level3 Item and Level3 Item doesn't exist.

If I make Level3 a link to the directory like [Level3](level3/) and move the nav items into that directories md, it generated the nav appropriately.

oprypin commented 1 year ago

This is probably not about the plugin, any kind of nav can cause it, both mkdocs and readthedocs themes handle nesting poorly. What theme are you using?

oprypin commented 1 year ago

Or based on your example, another thing this could be is duplicate of https://github.com/oprypin/mkdocs-literate-nav/issues/14

smokedlinq commented 1 year ago

material, let me test switching back to 4 spaces

smokedlinq commented 1 year ago

4 space navigation produces the same result as 2

oprypin commented 1 year ago

First of all, that is really surprising, there's no way that Python-Markdown works with 2 spaces just like it does with 4. But OK.

Could you paste your mkdocs.yml

smokedlinq commented 1 year ago

Also, if I make Level3 a link like [Level3](level3/index.md) then the link still goes to Level3 Item but now the menu shows a None item to the link for Level3

smokedlinq commented 1 year ago

mkdocs.yml

theme:
  name: material
  language: en
  custom_dir: overrides
  icon:
    edit: material/pencil
    view: material/eye
  font:
    text: Roboto
    code: Roboto Mono
  palette:
    - media: "(prefers-color-scheme: light)"
      scheme: default
      primary: black
      accent: deep orange
      toggle:
        icon: material/weather-sunny
        name: Switch to dark mode
    - media: "(prefers-color-scheme: dark)"
      scheme: slate
      primary: black
      accent: deep orange
      toggle:
        icon: material/weather-night
        name: Switch to light mode
  logo: logo.png
  features:
    - navigation.instant
    - navigation.indexes
    - navigation.tabs
    - navigation.tabs.sticky
    - navigation.top
    - navigation.sections
    - content.action.edit
    - content.action.view
    - content.code.copy

extra:
  generator: false

extra_css:
  - site.css

extra_javascript:
  - site.js

plugins:
  - search:
      separator: '[\s]+'
      lang: en
  - redirects
  - git-authors:
      exclude:
        - index.md
  - mkdocs-jupyter
  - literate-nav:
      nav_file: toc.md
      tab_length: 2
  - minify:
      minify_html: true
      minify_js: true
      minify_css: true
      htmlmin_opts:
        remove_comments: true

markdown_extensions:
  - meta
  - admonition
  - tables
  - toc:
      permalink: "🔗"
  - attr_list
  - def_list
  - md_in_html
  - mdx_truly_sane_lists
  - pymdownx.critic
  - pymdownx.caret
  - pymdownx.keys
  - pymdownx.mark
  - pymdownx.tilde
  - pymdownx.details
  - pymdownx.highlight:
      anchor_linenums: true
      line_spans: __span
      pygments_lang_class: true
  - pymdownx.inlinehilite
  - pymdownx.snippets
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:pymdownx.superfences.fence_code_format
  - pymdownx.pathconverter
  - pymdownx.tabbed
  - pymdownx.tasklist:
      custom_checkbox: true
oprypin commented 1 year ago
    - navigation.indexes

I'm sure that's what makes it happen

oprypin commented 1 year ago

If you want properly behaving navigation indexes, please use https://github.com/oprypin/mkdocs-section-index and not navigation.indexes. Or if you're not intentionally relying on this setting, just delete it

smokedlinq commented 1 year ago

Thank you for the help so quickly!