Replies: 1 comment
-
Hello @madjxatw, mkdocs-material/src/templates/base.html Line 195 in 15f1506 So there is no config option to get the result you want. However, to get what you want, you can use a hook that would modify the Here is a quick example, with debug prints to see what is happening, there is no validation or safety checks for fat fingering the keyboard nor proper logging, but it's enough to get you started ✌️ Hook
from pprint import pprint as pp
class CopyPassAlong:
context = None
obj = None
def on_page_context(context, page, config, nav):
features = context["config"]["theme"]["features"]
# Skip non-blog pages
if not page.url.startswith("blog"):
print(f"non blog: {page.url}")
pp(features)
return
print(f"blog - before change: {page.url}")
pp(features)
# Store the context and copy in global class to pass it along to the other event
CopyPassAlong.context = context
CopyPassAlong.obj = list(features)
# Enable the feature on the blog page
context["config"]["theme"]["features"].append("navigation.sections")
def on_post_page(output, page, config):
# Skip non-blog pages
if not page.url.startswith("blog"):
return
print(f"blog - after change - before restore: {page.url}")
features = CopyPassAlong.context["config"]["theme"]["features"]
pp(features)
# Restore the features from the copy
CopyPassAlong.context["config"]["theme"]["features"] = CopyPassAlong.obj
print(f"blog - after restore: {page.url}")
features = CopyPassAlong.context["config"]["theme"]["features"]
pp(features) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I disables
navigation.sections
to get a collapsible navigation sidebar, but this leads to theArchive
andCategories
sections on the blog home page being collapsed as well.I want to let
Archive
andCategories
rendered as groups in sidebar while keeping other non-blog docs having a collapsible navigation sidebar. How to achieve this?Beta Was this translation helpful? Give feedback.
All reactions