Skip to content

Is there a way to use macros to change navigation conditionally? #234

Answered by fralau
hozn asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks a lot for your appreciation! I had not thought about your use case, but it makes a lot of sense.

Indeed, Mkdocs-Macros plugin won't work directly with the snippet above, since the plugin renders only the markdown files.

You could take a number of approaches, depending on your use case and circumstances. 🤔 You wish to make this choice at build/serve time, right?

In that case, why don't follow your idea through, but without the plugin? A simple solution could be: you create source config file called, e.g. mkdocs_source.yaml which contains exactly the code you suggested.

You could write a Python utility that does more or less this:

  1. Read the flags from a separate config file (e.g. doc…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hozn
Comment options

Answer selected by hozn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants