Skip to content

Commit 5042cb9

Browse files
MridulSpre-commit-ci[bot]drammock
authored
Expose logo_link in theme.conf (#1850)
This fixes #1664, I'm not a 100% sure if this is enough to let downstream projects set custom links. Should I also add any specific docs here? I think we should also be able to remove this config setting if we can move to theme.toml (as in #1776). --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel McCloy <[email protected]>
1 parent 1fa7319 commit 5042cb9

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/pydata_sphinx_theme/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ def update_config(app):
158158
theme_logo = {}
159159
if not isinstance(theme_logo, dict):
160160
raise ValueError(f"Incorrect logo config type: {type(theme_logo)}")
161+
theme_logo_link = theme_options.get("theme_logo_link")
162+
if theme_logo_link:
163+
theme_logo["link"] = theme_logo_link
161164
theme_options["logo"] = theme_logo
162165

163166

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-logo.html

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{# Displays the logo of your documentation site, in the header navbar. #}
22
{# Logo link generation -#}
3-
{% if not theme_logo.get("link") %}
4-
{% set href = pathto(root_doc) %}
5-
{% elif hasdoc(theme_logo.get("link")) %}
6-
{% set href = pathto(theme_logo.get("link")) %} {# internal page #}
3+
{% if theme_logo_link %}
4+
{% set href = theme_logo_link %}
75
{% else %}
8-
{% set href = theme_logo.get("link") %} {# external url #}
6+
{% if not theme_logo.get("link") %}
7+
{% set href = pathto(root_doc) %}
8+
{% elif hasdoc(theme_logo.get("link")) %}
9+
{% set href = pathto(theme_logo.get("link")) %} {# internal page #}
10+
{% else %}
11+
{% set href = theme_logo.get("link") %} {# external url #}
12+
{% endif %}
913
{% endif %}
1014

1115
{#- Logo HTML and image #}

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/theme.conf

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ check_switcher = True
3434
pygments_light_style = a11y-high-contrast-light
3535
pygments_dark_style = a11y-high-contrast-dark
3636
logo =
37+
logo_link =
3738
surface_warnings = True
3839
back_to_top_button = True
3940

0 commit comments

Comments
 (0)