Replies: 1 comment 2 replies
-
It is possible to have conditional content at the page generation stage with something like a hook or using the macros plugin. You can then just add a link as a way to switch between the different versions. Has the advantage of not requiring JavaScript. If that is not a good option for your then you might need a customization that achieves the desired effect with some JavaScript. You might get an idea of how to implement this by looking at the implementation of the color palette toggle. Depends on the specifics of your use case which of these would be preferable. I had a look at the discussions to see if this has come up before but did not have any joy with the keywords I chose. Have a look, perhaps you have more luck. I am sure that using the color palette toggle for something else has come up before?! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I haven't been able to find any mention of adding conditional content in Mkdocs or Material so far. Is this possible?
We have some readers who are in a special group, and certain content only applies to them. I'd like to be able to add a toggle button to the header that lets them turn Special Content "On". Then, as they browse, certain additional content would appear throughout the pages. If that content isn't relevant, they can just switch the button to "Off."
Our docs site is unauthenticated, so it would need to be a manual toggle like this.
Is adding conditional text in this way supported by Material?
Thanks for your advice!
Beta Was this translation helpful? Give feedback.
All reactions