{%- if page %}
{%- set resource = page %}
{%- elif section %}
{%- set resource = section %}
{%- endif %}

<!DOCTYPE html>
<html lang="{{ lang }}">

<head>
  <meta charset="utf-8">
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">

  <meta name="description" content="{{ resource.description }}">

  {% block rss %}
  <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ get_url(path="rss.xml", trailing_slash=false) }}">
  {% endblock %}

  <link rel="canonical" href="{{ config.base_url | safe }}{{ resource.path | safe }}">

  {%- set preview_image = 'images/screenshots/prague.jpg' -%}
  {%- if resource.extra.preview_image -%}
  {%- set preview_image = resource.extra.preview_image -%}
  {%- elif resource.assets %}
  {%- set basename = resource.assets[0] | split(pat='/') | last %}
  {%- if basename is ending_with('.jpg') or basename is ending_with('.jpeg') or basename is ending_with('.png') %}
  {%- set preview_image = resource.path ~ basename -%}
  {%- endif %}
  {%- endif %}
  <meta property="og:image" content="{{ get_url(path=preview_image) }}">
  <meta property="og:url" content="{{ current_url | safe }}">
  <meta property="og:type" content="website">
  <meta property="og:title" content="{{ resource.title }}">
  {%- if resource.description -%}
  <meta property="og:description" content="{{ resource.description }}">
  {%- endif -%}

  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:title" content="{{ resource.title }}">
  {%- if resource.description -%}
  <meta name="twitter:description" content="{{ resource.description }}">
  {%- endif -%}

  <meta name="apple-itunes-app" content="app-id=1567437057">
  <meta name="wikidata" content="Q107078602">

  {% if resource.date -%}
  <meta property="article:published_time" content="{{ resource.date }}">
  {%- endif -%}

  {%- block meta -%}{%- endblock %}

  <!-- TODO: Use get_url everywhere when it works, also with cachebust=true,
  see https://github.com/getzola/zola/issues/1570 -->
  <link href="/main.css?h={{ get_file_hash(path='sass/main.scss', sha_type=256, base64=false) }}" rel="stylesheet" type="text/css">

  <title>{{ resource.title }}</title>

  {# TODO: Replace 'en' with config.default_language after upgrading Zola #}
  {%- if lang == 'en' %}
  {% include 'language_redirect.html' %}
  {% endif -%}
</head>

<body>
  <header>
    {% include 'top_menu.html' %}
  </header>

  <main>
    {% block content %}{% endblock %}
  </main>

  <footer>
    {% include 'bottom_menu.html' %}
    <p>
      <span>© 2022 <a href="mailto:legal@organicmaps.app">Organic Maps OÜ</a>, reg. code 16225385</span>
      <span>Harju maakond, Tallinn, Kristiine linnaosa, A. H. Tammsaare tee 47, 11316, Estonia</span>
    </p>
  </footer>

</body>

</html>