diff --git a/pages/conf.py b/pages/conf.py index 1547abd..fd6409e 100644 --- a/pages/conf.py +++ b/pages/conf.py @@ -42,8 +42,8 @@ copybutton_prompt_is_regexp = True tags_create_tags = True tags_extension = ['md'] tags_output_dir = 'tags' -tags_overview_title = 'Tags' -tags_page_title = 'Tags' +tags_overview_title = '{fas}`tags` Tags' +tags_page_title = '{fas}`tag` Tag' tags_create_badges = True tags_badge_colors = { 'python': 'primary', @@ -114,3 +114,38 @@ html_theme_options = { # bg3 #665c54 # bg4 #7c6f64 # gray #928374 + + +SIDEBAR_MAXDEPTH = 2 + + +def setup(app): + """Run some additional steps after the Sphinx builder is initialized""" + app.connect('builder-inited', patch_furo_sidebar_toctree) + + +def patch_furo_sidebar_toctree(app): + """Monkey-patch Furo's sidebar toctree to override its max depth. This is done to include the + tags overview page generated by sphinx-tags without adding redundant items to the tree. + Otherwise, a page shows up once in the main tree, and then an additional time under every tag + it's associated with. + + Furo made the (sensible) design choice to always display the entire site in the sidebar tree, + and doesn't provide a way to limit the tree depth. Reference: + https://github.com/pradyunsg/furo/pull/128 + + Note: This involves private utility methods, and is likely to break in future versions of Furo. + """ + import furo + from furo import _compute_navigation_tree + + def mod_compute_navigation_tree(context): + toctree = context["toctree"] + + def mod_toctree(maxdepth=-1, **kwargs): + return toctree(maxdepth=SIDEBAR_MAXDEPTH, **kwargs) + + context["toctree"] = mod_toctree + return _compute_navigation_tree(context) + + furo._compute_navigation_tree = mod_compute_navigation_tree diff --git a/pages/index.md b/pages/index.md index 30e3f6f..f3c72f2 100644 --- a/pages/index.md +++ b/pages/index.md @@ -20,5 +20,6 @@ open_source succulents photography about_site +tags/tagsindex asdf ``` diff --git a/templates/page.html b/templates/page.html index 0d1a823..3bf8ff2 100644 --- a/templates/page.html +++ b/templates/page.html @@ -89,10 +89,6 @@ -
- Tags -
-
{%- if last_updated -%}
Last updated on {{ last_updated }}