{% extends "_layout.html" %}

{% block title %}{{ post.title }}{% endblock title %}

{% block meta_tags %}
  {{ super() }}
  {% if post.description %}
    <meta name="description" content="{{ post.description }}">
  {% endif %}
  {% if post.tags %}
    <meta name="keywords" content="{{ post.tags }}">
  {% endif %}

  {# Open Graph Tags #}
  <meta property="og:type" content="article">
  {% if 'draft' not in post.meta %}
    <meta property="og:url" content="{{ url_for('post', year=post.meta['published'].year, month=post.meta['published'].strftime('%m'), day=post.meta['published'].strftime('%d'), path=post.path, _external=True) }}">
  {% endif %}
  <meta property="og:title" content="{{ post.title }}">
  <meta property="og:description" content="{{ post.description }}">
  {% if post.image or SITE_LOGO %}
    <meta property="og:image" content="{{ url_for('static', filename=post.image or SITE_LOGO, _external=True) }}">
  {% endif %}

  {% if post.facebook_url or DEFAULT_AUTHOR_FACEBOOK %}
    <meta property="article:author" content="{{ post.facebook_url or DEFAULT_AUTHOR_FACEBOOK }}">
  {% endif %}

  {# Twitter Specific Tags #}
  {% if post.twitter_username or DEFAULT_AUTHOR_TWITTER %}
    <meta name="twitter:creator" content="{{ post.twitter_username or DEFAULT_AUTHOR_TWITTER }}">
  {% endif %}
{% endblock meta_tags %}

{% block content %}
  {# TODO: use post.image #}
  <article>
    <h1>{{ post.title }}</h1>
    {% if post.subtitle %}
      <h2 class="subheading">{{ post.subtitle }}</h2>
    {% endif %}
    {% if SHOW_AUTHOR %}
        <span class="meta">
          Posted by <a href="{{ url_for('author', author = post.author or DEFAULT_AUTHOR) }}">{{ post.author }}</a> on {% if post.published %}{{ post.published.strftime('%Y-%m-%d') }}{% endif %}
        </span>
    {% endif %}
    {{ post.html|safe }}

    <hr class="small">
    {% if post.tags %}
      <p><strong>Tags</strong></p>
      {% for tag in post.meta.get('tags') %}
        <a class="tag" href="{{ url_for('tag', tag=tag) }}">{{ tag }}</a>
      {% endfor %}
    {% endif %}
  </article>
{% endblock content %}
