<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

    {% comment %}
    <!--
      There are three situations:

      1. We have a page title and it needs translation (it starts with "titles.blabla").
      2. We have a page title and it has to be as it is.
      3. We don't have a page title (e.g. the main page)
    -->
    {% endcomment %}
    {% if page.title %}
      {% if page.title contains "titles." %}
        {% capture title %}{{ site.title }} - {% t page.title %}{% endcapture %}
        {% capture raw_title %}{% t page.title %}{% endcapture %}
      {% else %}
        {% capture title %}{{ site.title }} - {{ page.title }}{% endcapture %}
        {% capture raw_title %}{{ page.title }}{% endcapture %}
      {% endif %}
    {% else %}
      {% capture title %}{{ site.title }}{% endcapture %}
      {% capture raw_title %}{% endcapture %}
    {% endif %}

    <title>{{ title }}</title>

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    {% capture description %}{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}{% endcapture %}
    <meta name="description" content="{{ description }}" />

    {% comment %}<!-- OpenGraph protocol -->{% endcomment %}
    {% if site.lang == "ca" %}
    <meta property="og:locale" content="ca_ES" />
    <meta property="og:locale:alternate" content="en_US" />
    <meta property="og:url" content="http://jo.mssola.com{{ page.url }}" />
    {% else %}
    <meta property="og:locale" content="en_US" />
    <meta property="og:locale:alternate" content="ca_ES" />
    <meta property="og:url" content="http://jo.mssola.com/en{{ page.url }}" />
    {% endif %}
    <meta property="og:title" content="{{ title }}" />
    <meta property="og:description" content="{{ description }}" />

    {% render_type_tags %}

    {% comment %}<!-- Twitter stuff -->{% endcomment %}
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:site" content="@miquelssola" />
    <meta name="twitter:creator" content="@miquelssola" />
    <meta name="twitter:description" content="{{ description }}" />
    <meta name="twitter:title" content="{{ title }}" />
    {% render_og_image %}

    {% comment %}<!-- We have the same CSS file for all languages -->{% endcomment %}
    <link href="{{ "/stylesheets/main.css" | prepend: site.baseurl_root }}" rel="stylesheet" type="text/css" />

    {% comment %}<!-- We have the same JS file for all languages -->{% endcomment %}
    <script src="{{ "/javascripts/dist/main.min.js" | prepend: site.baseurl_root }}"></script>

    {% comment %}<!-- Feeds -->{% endcomment %}
    <link href="/feed.xml" type="application/rss+xml" rel="alternate" title="Entrades al blog en català" />
    <link href="/feed.en.xml" type="application/rss+xml" rel="alternate" title="Blog posts in english" />

    {% include favicon.html %}
</head>
<body>
  {% include header.html %}

  <main class="page-content" aria-label="Content">
    <div class="wrapper">
      {{ content }}
    </div>
  </main >

  {% include footer.html %}
</body>
</html>
