lukasgeiter / mkdocs-awesome-pages-plugin

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

Unnecessary nesting of pages (section with just a single page) #1

Closed vsimko closed 6 years ago

vsimko commented 6 years ago

This is related to issue https://github.com/mkdocs/mkdocs/issues/1347

I would like to keep each page in a separate directory that contains a single index.md together with all images used on that page. Here is an example

docs/
docs/section1/page11/index.md (# My Page1 in Section1)
docs/section1/page11/image1.png (used from docs/section1/page11/index.md)
docs/page2/index.md (# My Page2)
docs/page2/image2.png (used from docs/page2/index.md)
docs/index.md (# About)

I would like to see this:

pages:
  - About: index.md
  - My Page2: page2/index.md
  - Section 1:
    - My Page1 in Section1: section1/page11/index.md

Instead, I see the following (unnecessary nesting of page2):

pages:
  - About: index.md
  - Page2:
    - My Page2: page2/index.md
  - Section 1:
    - My Page1 in Section1: section1/page11/index.md

Is there an option to automatically "collapse" sections that have just a single nested page ?

lukasgeiter commented 6 years ago

That's currently not implemented. I really like the idea though and will start working on this feature soon 👍

vsimko commented 6 years ago

I already implemented a quick and dirty transformation of the "pages" YAML using javascript: Maybe it helps: https://gist.github.com/vsimko/9ecd8b51e40ac63a502824db100d2e78

lukasgeiter commented 6 years ago

Collapsing of single nested pages is done and released 🙂

lukasgeiter commented 6 years ago

I realized that having the feature enabled by default might lead to unwanted results for a majority of users so I've disabled it by default in the latest release. Simply enable it using the collapse_single_pages option in your mkdocs.yml.

vsimko commented 6 years ago

This is awesome! I'm now using the plugin in our project docs (github here)