Fix support for logos as urls (#1171)

* Fix support for logos as urls

Sphinx since 4.0 appears to support html_logo to also contain urls.  As
a consequence, the other themes in sphinx appear to be just using the
new logo_url variable, and in this theme that fixes support for it, too.

* Add backwards compatibility and add favicon_url

Co-authored-by: Aaron Carlisle <carlisle.b3d@gmail.com>
This commit is contained in:
Simon Hausmann 2021-07-20 02:16:54 +02:00 committed by GitHub
parent 380647d159
commit 3532ffc89b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,7 +42,11 @@
{#- FAVICON #} {#- FAVICON #}
{%- if favicon %} {%- if favicon %}
{%- if sphinx_version_info < (4, 0) -%}
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/> <link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
{%- else %}
<link rel="shortcut icon" href="{{ favicon_url }}"/>
{%- endif %}
{%- endif -%} {%- endif -%}
{#- CANONICAL URL (deprecated) #} {#- CANONICAL URL (deprecated) #}
@ -139,7 +143,11 @@
{#- Not strictly valid HTML, but it's the only way to display/scale {#- Not strictly valid HTML, but it's the only way to display/scale
it properly, without weird scripting or heaps of work it properly, without weird scripting or heaps of work
#} #}
{%- if sphinx_version_info < (4, 0) -%}
<img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="{{ _('Logo') }}"/> <img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="{{ _('Logo') }}"/>
{%- else %}
<img src="{{ logo_url }}" class="logo" alt="{{ _('Logo') }}"/>
{%- endif %}
{%- endif %} {%- endif %}
</a> </a>