{% extends "base.html" %}

{% block content %}
{%- set date_format = macros_translate::translate(key="date_format", default="%B %d, %Y", language_strings=language_strings) -%}
{%- set date_locale = macros_translate::translate(key="date_locale", default="en_US", language_strings=language_strings) -%}
<article>
	{%- if page.extra.banner -%}
		<div id="banner-container">
			<img id="banner" class="full-bleed" src="{{ current_url | safe }}{{ page.extra.banner }}" />
		</div>
	{%- endif -%}

	<h1 {% if page.extra.banner %}class="banner-margin"{%- endif -%}>{{ page.title }}</h1>

	{%- if page.date -%}
		<small>
			<time datetime="{{ page.date | date(format=' %+') }}" pubdate>
				{{- macros_translate::translate(key="published", default="Published on", language_strings=language_strings) }}
				{{ page.date | date(format=date_format, locale=date_locale) -}}
			</time>
			{%- if page.updated -%}
				<span> • </span>
				<time datetime="{{ page.updated | date(format=' %+') }}" pubdate>
					{{- macros_translate::translate(key="updated", default="Updated on", language_strings=language_strings) }}
					{{ page.updated | date(format=date_format, locale=date_locale) -}}
				</time>
			{%- endif -%}
			{%- if page.authors -%}
				<span> • {% include "partials/authors.html" -%}</span>
			{%- endif -%}

			{%- if config.extra.show_read_time -%}
				{%- set words = page.content | striptags | safe | wordcount -%}
				{%- set words_per_minute = config.extra.words_per_minute | default(value=200) -%}
				{%- set number_of_minutes = words / words_per_minute | round -%}
				{%- if number_of_minutes == 0 -%}
					{%- set number_of_minutes = 1 -%}
				{%- endif -%}
					<span> • </span>
					<span>{{ macros_translate::translate(key="minutes_read", number=number_of_minutes, default="$NUMBER minute read", language_strings=language_strings) }}</span>
			{%- endif -%}
		</small>
	{%- endif -%}

	{%- include "partials/statements.html" -%}

	{%- if page.extra.toc -%}
		<h2>{{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}</h2>
		<ul>
			{%- for h1 in page.toc -%}
				<li>
					<a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
					{%- if h1.children -%}
						<ul>
							{%- for h2 in h1.children -%}
								<li>
									<a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
								</li>
							{%- endfor -%}
						</ul>
					{%- endif -%}
				</li>
			{%- endfor -%}
		</ul>
	{%- endif -%}

	{{ page.content | safe }}
</article>

{%- if page.extra.comments.id -%}
	{% include "partials/comments.html" %}
{%- endif -%}

{%- if page.lower or page.higher -%}
	<hr />
	<nav id="post-nav">
		{%- if page.higher -%}
			<a class="post-nav-item post-nav-prev" href="{{ page.higher.permalink }}">
				<div class="nav-arrow">{{ macros_translate::translate(key="previous", default="Previous", language_strings=language_strings) }}</div>
				<span class="post-title">{{ page.higher.title }}</span>
			</a>
		{%- endif -%}
		{%- if page.lower -%}
			<a class="post-nav-item post-nav-next" href="{{ page.lower.permalink }}">
				<div class="nav-arrow">{{ macros_translate::translate(key="next", default="Next", language_strings=language_strings) }}</div>
				<span class="post-title">{{ page.lower.title }}</span>
			</a>
		{%- endif -%}
	</nav>
{%- endif -%}

<div class="dialog-buttons">
	<a class="inline-button" href="#top">{{ macros_translate::translate(key="go_to_top", default="Go to Top", language_strings=language_strings) }}</a>
	{%- if config.extra.issues_url -%}
		<a class="inline-button colored external" href="{{ config.extra.issues_url }}">
			{{- macros_translate::translate(key="file_an_issue", default="File an Issue", language_strings=language_strings) -}}
		</a>
	{%- endif -%}
</div>
{% endblock content %}
