{% extends "base.html" %}

{% block extrahead %}
  {{ super() }}
  {% if config.extra.algolia and config.extra.algolia.app_id and config.extra.algolia.api_key and config.extra.algolia.index_name %}
  <script>
    window.__DOCSEARCH_CONFIG__ = {
      appId: "{{ config.extra.algolia.app_id }}",
      apiKey: "{{ config.extra.algolia.api_key }}",
      indexName: "{{ config.extra.algolia.index_name }}"
    };
  </script>
  {% endif %}
  {% if config.extra.version and config.extra.version.default %}
  <script>
    document.addEventListener("DOMContentLoaded", function () {
      var header = document.querySelector(".md-header__inner");
      if (!header || header.querySelector(".md-version-badge")) return;
      var badge = document.createElement("a");
      badge.className = "md-version-badge";
      badge.textContent = "{{ config.extra.version.default }}";
      badge.href = "https://github.com/open-jarvis/OpenJarvis/releases";
      badge.rel = "noopener";
      var source = header.querySelector(".md-header__source");
      if (source) {
        header.insertBefore(badge, source);
      } else {
        header.appendChild(badge);
      }
    });
  </script>
  {% endif %}
{% endblock %}
