{#
  Use our theme's favicon by default.  We do it here layout.html since the
  "html_favicon" configuration option unfortunately can't be set by the theme
  directly.  The "favicon" variable is used by Sphinx versions < 4;
  "favicon_url" by newer versions.
#}
{% if not favicon %}
{%   set favicon     = 'favicon.ico' %}
{%   set favicon_url = pathto('_static/' + favicon, 1) %}
{% endif %}

{% extends "sphinx_rtd_theme/layout.html" %}
{#
  Most of this block is copied from sphinx_rtd_theme version 0.5.0-1-gaa71fd6.

  Tweaks were necessary for our theme to provide a default logo, since Sphinx's
  html_logo configuration option (template variable "logo" below) can't be set
  by the theme *and also* can't refer to a theme-provided file when set by the
  doc project's conf.py.

  `theme_logo_only` is set via a project's conf.py -> `html_theme_options` ->
  `logo_only` value (default: false). In the context of Nextstrain we use this
  to determine whether or not to display the subproject name, version

  We also adjust the rendering of the project name to remove the home icon.
#}
{% block sidebartitle %}

{% set logo = logo if logo else 'nextstrain-logo.svg' if theme_logo else '' %}

{% if logo %}
  <a href="https://nextstrain.org">
    <img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="{{ _('Logo') }}"/>
  </a>
{% endif %}

{% if not theme_logo_only %}
  <div class="subproject">
    <a href="{{ pathto(master_doc) }}" class="project-name" alt="{{ _("Documentation Home") }}">
      {{ project }}
    </a>

    {#
      NOTE the version only works on RTD (not locally) as the variables `nav_version` and
      `current_version` don't seem to be set on a local build.
    #}
    {%- set nav_version = version %}
    {% if READTHEDOCS and current_version %}
      {%- set nav_version = current_version %}
    {% endif %}
    {% if nav_version %}
      <span>
        version: {{ nav_version }}
      </span>
    {% endif %}

  </div>

  <div>
    (<a href="https://docs.nextstrain.org">Click here</a> to return to the main nextstrain docs)
  </div>

{% endif %}

{% include "searchbox.html" %}

{% endblock %}
