lukasgeiter / mkdocs-awesome-pages-plugin

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

Allow `mkdocs-gen-files` generated content #78

Closed thejcannon closed 10 months ago

thejcannon commented 11 months ago

:wave: Loving the plugin!

Currently also loving https://github.com/oprypin/mkdocs-gen-files, but noticed that if I generate navs, or pages referenced by my static navs, they don't end up making it to the generated docsite.

E.g. mkdocs.yml

plugins:
  - gen-files:
      scripts:
        - generate_reference_docs.py
  - awesome-pages:
      filename: .nav.yaml

generate_reference_docs.py

with mkdocs_gen_files.open(f"reference/global-options.md", "w") as f:
    f.write("Hello world!\n")
with mkdocs_gen_files.open(f"reference/goals/index.md", "w") as f:
    f.write("# Goals!\n")
with mkdocs_gen_files.open(f"reference/goals/.nav.yaml", "w") as f:
    f.write("nav:\n  - index.md\n")

along with:

$ tree -a docs/markdown/reference
docs/markdown/reference
└── .nav.yaml
$ cat docs/markdown/reference/.nav.yaml 
nav:
  - Global Options: global-options.md
  - Goals: goals

Results in Reference being in the nav, but is "flat". No expand arrow.

Additionally, the pages do exist, /reference/global-options is a valid URL and gives what I expect.

thejcannon commented 11 months ago

Hmm, so poking around mkdocs and https://github.com/oprypin/mkdocs-gen-files, I suspect that that plugin ought to define on_nav and allow customization. I'll file an issue over there and close one when the other is complete.

thejcannon commented 11 months ago

Nevermind, I think I got this working on this plugin, using the Files provided by mkdocs instead of scraping the docs_dir directly.

I'll try and whip up a PR today :smile:

lukasgeiter commented 11 months ago

Keep in mind that under normal circumstances .nav.yml wouldn't be included in Files.

If I understand mkdocs-gen-files correctly, the files are temporarily created somewhere outside of docs_dir. Maybe you can try to get my plugin to read the .nav.yml file from there.

thejcannon commented 11 months ago

OK, today might be a stretch. I got it to respect generated .md files pretty easily.

Generated navs is a bit harder :smile: