{#  -*- coding: utf-8 -*- #}
{% import 'feeds_translations_helper.tmpl' as feeds_translations with context %}

{% macro html_headstart() %}
<!DOCTYPE html>
<html

prefix='
og: http://ogp.me/ns# article: http://ogp.me/ns/article#
{% if comment_system == 'facebook' %}
fb: http://ogp.me/ns/fb#
{% endif %}
'
{% if is_rtl %}
dir="rtl"
{% endif %}

lang="{{ lang }}">
    <head>
    <meta charset="utf-8">
    {% if description %}
    <meta name="description" content="{{ description|e }}">
    {% endif %}
    <meta name="viewport" content="width=device-width, initial-scale=1">
    {% if title == blog_title %}
        <title>{{ blog_title|e }}</title>
    {% else %}
        <title>{{ title|e }} | {{ blog_title|e }}</title>
    {% endif %}

    {{ html_stylesheets() }}
    <meta name="theme-color" content="{{ theme_color }}">
    {% if meta_generator_tag %}
    <meta name="generator" content="Nikola (getnikola.com)">
    {% endif %}
    {{ html_feedlinks() }}
    <link rel="canonical" href="{{ abs_link(permalink) }}">

    {% if favicons %}
        {% for name, file, size in favicons %}
            <link rel="{{ name }}" href="{{ file }}" sizes="{{ size }}"/>
        {% endfor %}
    {% endif %}

    {% if comment_system == 'facebook' %}
        <meta property="fb:app_id" content="{{ comment_system_id }}">
    {% endif %}

    {% if prevlink %}
        <link rel="prev" href="{{ prevlink }}" type="text/html">
    {% endif %}
    {% if nextlink %}
        <link rel="next" href="{{ nextlink }}" type="text/html">
    {% endif %}

    {% if use_cdn %}
        <!--[if lt IE 9]><script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    {% else %}
        <!--[if lt IE 9]><script src="{{ url_replacer(permalink, '/assets/js/html5.js', lang, url_type) }}"></script><![endif]-->
    {% endif %}

    {{ extra_head_data }}
{% endmacro %}

{% macro late_load_js() %}
    {% if use_cdn %}
        <script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.11.1/baguetteBox.min.js" integrity="sha256-ULQV01VS9LCI2ePpLsmka+W0mawFpEA0rtxnezUj4A4=" crossorigin="anonymous"></script>
    {% endif %}
    {% if use_bundles and use_cdn %}
        <script src="/assets/js/all.js"></script>
    {% elif use_bundles %}
        <script src="/assets/js/all-nocdn.js"></script>
    {% else %}
        {% if not use_cdn %}
            <script src="/assets/js/jquery.min.js"></script>
            <script src="/assets/js/popper.min.js"></script>
            <script src="/assets/js/bootstrap.min.js"></script>
            <script src="/assets/js/baguetteBox.min.js"></script>
        {% endif %}
    {% endif %}
    {% if date_fanciness != 0 %}
        {% if use_cdn %}
            <script src="https://cdn.jsdelivr.net/npm/luxon@3.3.0/build/global/luxon.min.js" integrity="sha256-Nn+JGDrq3PuTxcDfJmmI0Srj5LpfOFlKqEiPwQK7y40=" crossorigin="anonymous"></script>
        {% else %}
            <script src="/assets/js/luxon.min.js"></script>
        {% endif %}
        {% if not use_bundles %}
            <script src="/assets/js/fancydates.min.js"></script>
        {% endif %}
    {% endif %}
    {{ social_buttons_code }}
{% endmacro %}


{% macro html_stylesheets() %}
    {% if use_cdn %}
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.11.1/baguetteBox.min.css" integrity="sha256-cLMYWYYutHkt+KpNqjg7NVkYSQ+E2VbrXsEvOqU7mL0=" crossorigin="anonymous">
    {% endif %}
    {% if use_bundles and use_cdn %}
        <link href="/assets/css/all.css" rel="stylesheet" type="text/css">
    {% elif use_bundles %}
        <link href="/assets/css/all-nocdn.css" rel="stylesheet" type="text/css">
    {% else %}
        {% if not use_cdn %}
            <link href="/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
            <link href="/assets/css/baguetteBox.min.css" rel="stylesheet" type="text/css">
        {% endif %}
        <link href="/assets/css/rst.css" rel="stylesheet" type="text/css">
        <link href="/assets/css/code.css" rel="stylesheet" type="text/css">
        <link href="/assets/css/theme.css" rel="stylesheet" type="text/css">
        {% if has_custom_css %}
            <link href="/assets/css/custom.css" rel="stylesheet" type="text/css">
        {% endif %}
    {% endif %}
    {% if needs_ipython_css %}
        <link href="/assets/css/ipython.min.css" rel="stylesheet" type="text/css">
        <link href="/assets/css/nikola_ipython.css" rel="stylesheet" type="text/css">
    {% endif %}
{% endmacro %}

{% macro html_navigation_links() %}
    {{ html_navigation_links_entries(navigation_links) }}
{% endmacro %}

{% macro html_navigation_links_entries(navigation_links_source) %}
    {% for url, text in navigation_links_source[lang] %}
        {% if isinstance(url, tuple) %}
            <li class="nav-item dropdown"><a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{ text }}</a>
            <div class="dropdown-menu">
            {% for suburl, text in url %}
                {% if rel_link(permalink, suburl) == "#" %}
                    <a href="{{ permalink }}" class="dropdown-item active">{{ text }} <span class="sr-only">{{ messages("(active)", lang) }}</span></a>
                {% else %}
                    <a href="{{ suburl }}" class="dropdown-item">{{ text }}</a>
                {% endif %}
            {% endfor %}
            </div>
        {% else %}
            {% if rel_link(permalink, url) == "#" %}
                <li class="nav-item active"><a href="{{ permalink }}" class="nav-link">{{ text }} <span class="sr-only">{{ messages("(active)", lang) }}</span></a>
            {% else %}
                <li class="nav-item"><a href="{{ url }}" class="nav-link">{{ text }}</a>
            {% endif %}
        {% endif %}
    {% endfor %}
{% endmacro %}

{% macro html_feedlinks() %}
    {{ feeds_translations.head(classification=None, kind='index', other=False) }}
{% endmacro %}

{% macro html_translations() %}
    {% for langname in translations|sort %}
        {% if langname != lang %}
            <li class="nav-item"><a href="{{ _link("root", None, langname) }}" rel="alternate" hreflang="{{ langname }}" class="nav-link">{{ messages("LANGUAGE", langname) }}</a></li>
        {% endif %}
    {% endfor %}
{% endmacro %}
