{% extends "base_blog.html" %}

{% block title %}{{ article.title }} | {{ M_BLOG_NAME|e }}{% endblock %}

{% block head_links %}
  {{- super() -}}
  {# don't mind me, I'm just fixing whitespace from the previous line #}
  <link rel="canonical" href="{{ article.url|format_siteurl|e }}" />
{% endblock %}

{% block meta %}
  {% if article.description %}
  <meta name="description" content="{{ article.description|dehyphenate|striptags|e }}" />
  {% endif %}
{% endblock %}

{% block social %}
  {{- super() -}}
  {% if article.author and article.author.twitter %}
  <meta name="twitter:creator" content="{{ article.author.twitter }}" />
  {% endif %}
  {% if article.author and article.author.twitter_id %}
  <meta name="twitter:creator:id" content="{{ article.author.twitter_id }}" />
  {% endif %}
  <meta property="og:title" content="{{ article.title }}" />
  <meta name="twitter:title" content="{{ article.title }}" />
  <meta property="og:url" content="{{ article.url|format_siteurl|e }}" />
  {% if article.summary %}
  <meta property="og:description" content="{{ article.summary|dehyphenate|striptags|e }}" />
  <meta name="twitter:description" content="{{ article.summary|dehyphenate|striptags|e }}" />
  {% endif %}
  {% if article.cover %}
  <meta property="og:image" content="{{ article.cover|expand_link(article)|e }}" />
  <meta name="twitter:image" content="{{ article.cover|expand_link(article)|e }}" />
  <meta name="twitter:card" content="summary_large_image" />
  {% elif article.category.image %}
  <meta property="og:image" content="{{ article.category.image|expand_link(article)|e }}" />
  <meta name="twitter:image" content="{{ article.category.image|expand_link(article)|e }}" />
  {% elif M_SOCIAL_IMAGE %}
  <meta property="og:image" content="{{ M_SOCIAL_IMAGE|format_siteurl|e }}" />
  <meta name="twitter:image" content="{{ M_SOCIAL_IMAGE|format_siteurl|e }}" />
  {% endif %}
  {% if not article.cover %}
  <meta name="twitter:card" content="summary" />
  {% endif %}
  <meta property="og:type" content="article" />
{% endblock %}

{% macro badges() %}{% include "article_badges.html" %}{% endmacro %}

{% block content %}
  {% if article.cover %}
  <article id="m-jumbo"{% if article.class %} class="{{ article.class }}"{% endif %}>
    <header>
      <div id="m-jumbo-image" style="background-image: url('{{ article.cover|expand_link(article)|e }}');">
        <div id="m-jumbo-cover">
          <div class="m-container">
            <div class="m-row">
              <div class="{% if article.authors %}m-col-t-6 m-col-s-5{% else %}m-col-t-12 m-col-s-10{% endif %} m-push-s-1 m-text-left">{{ article.locale_date|e }}{% if article.status == 'draft' %} <span class="m-label m-dim">draft</span>{% endif %}</div>
              {% if article.authors %}
              <div class="m-col-t-6 m-col-s-5 m-push-s-1 m-text-right">{% for author in article.authors %}<a href="{{ author.url|format_siteurl|e }}">{{ author|e }}</a>{% endfor %}</div>
              {% endif %}
            </div>
            <div class="m-row">
              <div class="m-col-t-12 m-col-s-10 m-push-s-1 m-col-m-8 m-push-m-2">
                {% set title = article.title.split(' — ') %}
                <h1><a href="{{ article.url|format_siteurl|e }}" rel="bookmark" title="Permalink to {{ article.title }}">{{ title[0] }}</a></h1>
                {% if title|length >= 2 %}
                <h2>{{ title[1] }}</h2>
                {% endif %}
              </div>
            </div>
          </div>
        </div>
      </div>
      {% if article.summary and
            ((article.hide_summary is defined and article.hide_summary != 'True') or
             (article.hide_summary is not defined and not M_HIDE_ARTICLE_SUMMARY)) %}
      <div class="m-container">
        <div class="m-row">
          <div class="m-col-m-10 m-push-m-1 m-nopady">
            {{ article.summary|trim|indent(12) }}
          </div>
        </div>
      </div>
      {% endif %}
    </header>
    {% if article.content %}
    <div class="m-container m-container-inflatable">
      <div class="m-row">
        <div class="m-col-m-10 m-push-m-1 m-nopady">
          {% if article.archived == 'True' and M_ARCHIVED_ARTICLE_BADGE %}
          {{ M_ARCHIVED_ARTICLE_BADGE|render_rst|replace('{year}', article.date.year)|indent(8) }}
          {% endif %}
<!-- content -->
{{ article.content|trim }}
<!-- /content -->
          {% if article.category.badge or (article.author and article.author.badge) %}
          {{ badges()|indent(10) }}
          {% endif %}
        </div>
      </div>
    </div>
    {% endif %}
    <footer class="m-container">
      <div class="m-row">
        <div class="m-col-m-10 m-push-m-1 m-nopadb">
          {% macro footer() %}{% include "article_footer.html" %}{% endmacro %}
          {{ footer()|indent(10) }}
        </div>
      </div>
    </footer>
  </article>
  {% else %}
    <article class="m-col-m-10 m-nopadb">
      {% macro header() %}{% include "article_header.html" %}{% endmacro %}
      {{ header()|indent(6) }}
      <div class="m-clearfix-l"></div>
      {% if article.archived == 'True' and M_ARCHIVED_ARTICLE_BADGE %}
      {{ M_ARCHIVED_ARTICLE_BADGE|render_rst|replace('{year}', article.date.year)|indent(6) }}
      {% endif %}
      {% if article.content %}
<!-- content -->
{{ article.content|trim }}
<!-- /content -->
      {% endif %}
      {% if article.category.badge or (article.author and article.author.badge) %}
      {{ badges()|indent(6) }}
      {% endif %}
      <footer>
        {% macro footer() %}{% include "article_footer.html" %}{% endmacro %}
        {{ footer()|indent(8) }}
      </footer>
    </article>
    {% endif %}
{% endblock %}
