lukasgeiter / mkdocs-awesome-pages-plugin

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

Exclude Files from rendering when they are not in .pages file and no "..." is given #20

Closed alexander-matthiesen closed 3 years ago

alexander-matthiesen commented 4 years ago

I was thinking that if we don't declare the "..." and the file into the .pages-file, the specific file won't show up after rendering. Is there a Way to just render the Files that are in the .pages-file if there isn't a "..." added to the .pages-file?

Example 1:
- dir
  -  .pages
  - index.md
  - not-included.md

.pages-file:
title: Test
arrange:
    - index.md

Result: not-included.md should not be part of the generated documentation.

And now with dots:

Example 1:
- dir
  -  .pages
  - index.md
  - should-be-included.md

.pages-file:
title: Test
arrange:
    - index.md
    - ...

Result: not-included.md should be part of the generated documentation.
lukasgeiter commented 4 years ago

Unfortunately that's not possible in the current version. I like the idea though. In hindsight I would probably design it this way. But now that this would be a breaking change I have to consider whether to include it in the next major version or hide it behind an option...

alexander-matthiesen commented 4 years ago

An option would make sense, from my point of view. With that, a breaking change would be avoided. :)

kleinen commented 4 years ago

@lukasgeiter what about extending the hide setting that allows for targeted hiding of pages while keeping the default behavior of hiding the directory. The following suggestions allows for maintaining compatibility with the current interface while allowing for targeted hiding of specific or un-arranged pages. This could then be further expanded by adding a ... line item to the hide setting to change the default unspecified page behavior from "show after arranged pages" to "hide all un-arranged pages".

File structure for these suggestions are as follows:

Current behavior

Show un-arranged pages

index.md is shown before automated arrangement of non-included.md and bar.md.

title: Test
arrange:
    - index.md

Hide a directory

Entire foo directory is hidden from nav menu.

title: Test
arrange:
    - index.md
hide: true

Enhancement Suggestions

Hide a single page

index.md and bar.md are included, but not-included.md is hidden from the nav menu.

title: Test
arrange:
    - index.md
hide:
    - not-included.md

Hide all un-arranged pages

index.md are included, but not-included.md and 'bar.md` are hidden from the nav menu.

title: Test
arrange:
    - index.md
hide:
    - ...
kleinen commented 4 years ago

If reusing the hide setting is not desirable, a new one could be created. Maybe named exclude.

alexander-matthiesen commented 3 years ago

@lukasgeiter any updates on this?

lukasgeiter commented 3 years ago

@alexander-matthiesen Sorry for the long wait. I've recently started working on this and some other features. A new release should be ready soon. I'll keep you posted.

lukasgeiter commented 3 years ago

Hi everyone! I've just released v2.3.0 which brings the nav attribute to the .pages file. nav supports a few new tricks, but more importantly for this issue, it does not automatically add files that are not mentioned unless you explicitly specify a ... entry. See the updated README for details.

Mentioning people who upvoted, so they get a notification as well: @steph-ben, @fenik17


@kleinen I went with this approach instead of extending hide since I believe an explicit ... entry makes things more predictable and it aligns the behavior with mkdocs' own nav config. If anyone still has a need for a separate option to hide certain pages, please let me know (ideally by creating a new issue with your use case).