mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
fb418d6ec8
As we do with the other modules, we should include Managers too. Although there are many, it can be a little jarring not seeing the list of Managers when viewing a specific one. This requires we also show the "display name" (`Ansible`) in the sidebar, and then use the more verbose `Automated Dependency Updates for Ansible` as the header. To do this, we can utilise the `sidebar_label` (which was previously used in Docusarus, but unused by Material for MkDocs) via a custom hook to inject the label for the sidebar. Unfortunately this requires a custom hook, which will make moving away from Material for MkDocs (to Zensical) a little less straightforward. Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
25 lines
830 B
Python
25 lines
830 B
Python
# Uses sidebar_label from YAML frontmatter as the nav/sidebar title,
|
|
# while keeping the full title for the HTML <title> element (via page.meta.title).
|
|
#
|
|
# Because on_page_context fires per-page before each template render, we must
|
|
# fix ALL page titles on the first call so the sidebar is consistent across
|
|
# every rendered page.
|
|
|
|
_titles_fixed = False
|
|
|
|
|
|
def on_page_context(context, page, config, nav, **kwargs):
|
|
global _titles_fixed
|
|
if not _titles_fixed:
|
|
_titles_fixed = True
|
|
_fix_all_titles(nav)
|
|
return context
|
|
|
|
|
|
def _fix_all_titles(items):
|
|
for item in items:
|
|
if hasattr(item, 'children') and item.children:
|
|
_fix_all_titles(item.children)
|
|
if hasattr(item, 'meta') and 'sidebar_label' in getattr(item, 'meta', {}):
|
|
item.title = item.meta['sidebar_label']
|