{% macro feed(path, feed_name, type) %}
{% if path %}
<link href="{{ SITEURL }}/{{ path }}" type="application/{{ type }}+xml" rel="alternate" title="{{ SITENAME }} {{feed_name }}">
{% endif %}
{% endmacro -%}

{%- macro logo(name) -%}
<div class="social-icon">
  <img class="social-icon" src="{{ SITEURL }}/theme/images/logos/{{ name }}" alt="Logo {{ name }}">
</div>
{%- endmacro -%}

<!DOCTYPE html>
<html lang="{{ DEFAULT_LANG }}">
{#
 # Moeka Pelican Theme
 # Copyright (C) 2023 Daniel Schadt
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #}
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{% block title %}{{ SITENAME }}{% endblock %}</title>

    {# Feeds! #}
    {{ feed(FEED_ALL_ATOM, "Full Atom Feed", "atom") }}
    {{ feed(FEED_ALL_RSS, "Full RSS Feed", "rss") }}

    {% if FAVICON %}
    <link rel="icon" href="{{ SITEURL }}/{{ FAVICON }}">
    {% endif %}

    <link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/main.css">
    <link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/monokai.css">
  </head>
  <body>
    {# The site/side menu #}
    <div id="openSideBanner">
      <a id="hamburgerMenu" href="#sideBanner"><img src="{{ SITEURL }}/theme/images/hamburger.svg" alt="Show menu button"></a>
    </div>
    <div role="banner" id="sideBanner">
      <a id="hideMenu" href="#"><img src="{{ SITEURL }}/theme/images/hamburger.svg" alt="Hide menu button"></a>
      <header>
        {% if LOGO %}
        <div id="mainLogo">
          <img src="{{ SITEURL }}/{{ LOGO }}" alt="Logo">
        </div>
        {% endif %}
        <div id="mainTitle">
          <a href="{{ SITEURL }}">{{ SITENAME }}</a>
        </div>

        <nav id="menu">
          <ul>
            {% if DISPLAY_PAGES_ON_MENU %}
            {% for p in pages %}
            <li {% if p == page -%} class="active" {%- endif %}>
              <a href="{{ SITEURL }}/{{ p.url }}">{{ p.title }}</a>
            </li>
            {% endfor %}
            {% endif %}

            {% for link_title, link in MENUITEMS %}
            <li>
              <a href="{{ link }}">{{ link_title }}</a>
            </li>
            {% endfor %}

            {% if DISPLAY_CATEGORIES_ON_MENU %}
            {% for cat, _ in categories %}
            <li {% if cat == category -%} class="active" {%-endif%}>
              <a href="{{ SITEURL }}/{{ cat.url }}">{{ cat.name }}</a>
            </li>
            {% endfor %}
            {% endif %}
          </ul>
        </nav>
      </header>
    </div>

    {# Main content #}
    <div id="mainArea" role="main">
      {% block content %}
      {% endblock %}
    </div>

    {# Footer #}
    <footer>
      <div class="icons">
        {% if GITHUB %}
        <a href="{{ GITHUB }}" target="_blank">{{ logo("GitHub.svg") }}</a>
        {% endif %}

        {% if GITLAB %}
        <a href="{{ GITLAB }}" target="_blank">{{ logo("GitLab.svg") }}</a>
        {% endif %}

        {% if CODEBERG %}
        <a href="{{ CODEBERG }}" target="_blank">{{ logo("Codeberg.svg") }}</a>
        {% endif %}

        {% if MASTODON %}
        <a href="{{ MASTODON }}" target="_blank">{{ logo("Mastodon.svg") }}</a>
        {% endif %}
      </div>

      <p>&copy; {{ AUTHOR }}</p>
      {% if CONTENT_LICENCE %}
      <p id="licenceLine">
        {% if CONTENT_LICENCE.startswith("CC-BY-SA") %}
        <img src="{{ SITEURL }}/theme/images/cc/cc.svg" class="cc-icon" alt="CC">
        <img src="{{ SITEURL }}/theme/images/cc/by.svg" class="cc-icon" alt="BY">
        <img src="{{ SITEURL }}/theme/images/cc/sa.svg" class="cc-icon" alt="SA">
        {% endif %}
        The text of this website is licensed under {{ CONTENT_LICENCE }}.
      </p>
      {% endif %}
      {% if ATTRIBUTION %}
      <p>Pelican Theme <a href="https://codeberg.org/dunj3/moeka">moeka</a>, available under the GPL.</p>
      {% endif %}
    </footer>
  </body>
</html>