{% from 'header.html.j2' import header %}
{% import "meta.html.j2" as meta %}

<!DOCTYPE html>
<html lang="{{language}}" prefix="og: https://ogp.me/ns#">
  <head>
    {{ meta.general_fields(meta_info, current_url) }}

    {% if article %}
      {{ meta.object_graph_fields_article(meta_info, current_url) }}
      {{ meta.json_fd_article(meta_info, current_url) }}
    {% else %}
      {{ meta.object_graph_fields_website(meta_info, current_url) }}
      {{ meta.json_fd_website(meta_info, current_url) }}
    {% endif %}

    <link rel="stylesheet" href="/static/main.css">

    {% set photoswipe = photoswipe_settings() %}

    <link rel="stylesheet" href="{{photoswipe.stylesheet}}" crossorigin="anonymous" referrerpolicy="no-referrer" />

    {% if site.header_html %}
      {{ site.header_html | safe }}
    {% endif %}

  </head>
  <body>
    <div id="brigid-body">
      {{ header(language, site, article) }}

      {% block content %}{% endblock %}

      <script type="module">
        import Lightbox from '{{photoswipe.lightbox}}';

        const pswpModule = () => import('{{photoswipe.pswp}}')

        const galleries = document.querySelectorAll('.brigid-images');

        galleries.forEach(gallery => {

        const lightbox = new Lightbox({
          gallery: gallery,
          children: '.brigid-image-link',
          pswpModule: pswpModule
          });
        lightbox.init();
        });

      </script>

      {% set site_language = site.languages[language] %}

      <div class="brigid-footer brigid-article">
        <ul>
          {% if site_language.author %}
            <li>© {{ site_language.author }}</li>
          {% endif %}

          {% if site_language.license %}
            <li>
              {{translate_theme(language, 'license')|upper_first}}:
              <a href="{{ site_language.license.url }}" target="_blank">{{ site_language.license.name }}</a>
            </li>
          {% endif %}

          {% if site.content_repository %}
            <li>
              {{translate_theme(language, 'content_repository')|upper_first}}:
              <a href="{{ site.content_repository }}" target="_blank">{{site.content_repository}}</a>
            </li>
          {% endif %}

          {% if site.show_brigid_link %}
            <li>
              {{translate_theme(language, 'site_is_created_with')|upper_first}}
              <a href="{{brigid_repository()}}" target="_blank">Brigid</a>
            </li>
          {% endif %}

          <li>
            {{translate_theme(language, 'icons_attribution')|upper_first}}
          </li>
        </ul>
      </div>

      {% if site.footer_html %}
        {{ site.footer_html | safe }}
      {% endif %}

    </div>

  </body>
</html>
