From 12d698a827e78afb2e750202c67a6f7e832b2916 Mon Sep 17 00:00:00 2001 From: Vince Salvino Date: Mon, 22 Nov 2021 18:30:45 -0500 Subject: [PATCH 1/3] Allow customizing sidebar --- docs/customizing.rst | 32 ++++++++++++++++++++++++++++- sphinx_wagtail_theme/globaltoc.html | 5 +++++ sphinx_wagtail_theme/layout.html | 15 ++++++-------- sphinx_wagtail_theme/theme.conf | 1 - 4 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 sphinx_wagtail_theme/globaltoc.html diff --git a/docs/customizing.rst b/docs/customizing.rst index b6e8b501..4a1514d7 100644 --- a/docs/customizing.rst +++ b/docs/customizing.rst @@ -105,7 +105,7 @@ relevant rules: /* Import from Google Fonts, a CDN, or files in your _static folder. This Google Fonts import provides its own `@font-face` CSS; if providing your own font files, you'll also need to - provide your own @font-face` code. */ + provide your own `@font-face` code. */ @import url("https://fonts.googleapis.com/css2?family=Roboto"); /* Main font used throughout the docs. */ @@ -117,3 +117,33 @@ relevant rules: pre, code, kbd, samp { font-family: "Courier New", monospace; } + +Custom Sidebars +--------------- + +To add a custom sidebar (for example, add a link to sponsor your project), +create a custom HTML template and specify it in ``conf.py``: + +.. code-block:: python + + # Add any relative paths that contain templates. + templates_path = ["_templates"] + + # Custom sidebar templates, must be a dictionary that maps document names + # to template names. The theme default is just searchbox and globaltoc. + html_sidebars = {"**": [ + "searchbox.html", + "globaltoc.html", + "custom.html", # Your template here + ]} + +Then in ``_templates/custom.html``: + +.. code-block:: html + +

+ Sponsor my project! + Here's the link +

+ +Read more about `Sidebars in Sphinx `_ diff --git a/sphinx_wagtail_theme/globaltoc.html b/sphinx_wagtail_theme/globaltoc.html new file mode 100644 index 00000000..ea773a08 --- /dev/null +++ b/sphinx_wagtail_theme/globaltoc.html @@ -0,0 +1,5 @@ +
+ +
diff --git a/sphinx_wagtail_theme/layout.html b/sphinx_wagtail_theme/layout.html index f91cdedc..80dbeed8 100644 --- a/sphinx_wagtail_theme/layout.html +++ b/sphinx_wagtail_theme/layout.html @@ -110,17 +110,14 @@