{% extends "basic-ng/components/edit-this-page.html" %}
{% from "basic-ng/components/edit-this-page.html" import determine_page_edit_link with context %}

{%- macro furo_edit_button(url) -%}
<div class="edit-this-page">
  <a class="muted-link" href="{{ url }}" title="{{ _("Edit this page") }}">
    <svg aria-hidden="true" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
      <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
      <path d="M4 20h4l10.5 -10.5a1.5 1.5 0 0 0 -4 -4l-10.5 10.5v4" />
      <line x1="13.5" y1="6.5" x2="17.5" y2="10.5" />
    </svg>
    <span class="visually-hidden">{{ _("Edit this page") }}</span>
  </a>
</div>
{%- endmacro -%}

{% block link_available -%}
{{ furo_edit_button(determine_page_edit_link()) }}
{%- endblock %}

{% block link_not_available %}
{# Make nice things happen, on Read the Docs #}
{%- if READTHEDOCS and conf_py_path and page_source_suffix and github_user != "None" and github_repo != "None" and github_version and pagename and page_source_suffix %}
  {% set url = "https://github.com/" + github_user + "/" + github_repo + "/edit/" + github_version + conf_py_path + pagename + page_source_suffix %}
  {{ furo_edit_button(url) }}
{%- endif -%}
{% endblock %}
