{% 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) -%}
{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%}
<article>
	{%- if page.extra.banner -%}
		<div id="banner-container">
			<img id="banner" class="full-bleed{% if page.extra.banner_pixels %} pixels{% endif %}" src="{{ current_url ~ page.extra.banner }}" {% if config.markdown.lazy_async_image %}decoding="async" loading="lazy"{% endif %} />
		</div>
	{%- endif -%}

	<h1>{{ page.title }}</h1>

	{%- if page.date -%}
		<small>
			<time datetime="{{ page.date | date(format=' %+') }}">
				{{- 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=' %+') }}">
					{{- 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" -%}

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

	{{ 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 id="floating-buttons">
	{%- if page.extra.toc -%}
		<details id="toc">
			<summary title="{{ macros_translate::translate(key='table_of_contents', default='Table of Contents', language_strings=language_strings) }}"><i class="icon"></i></summary>
			<div id="toc-dropdown">
				<strong id="toc-dropdown-title">{{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}</strong>
				<div id="toc-dropdown-container">
					<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>
				</div>
			</div>
		</details>
	{%- endif -%}
	<a id="go-to-top" href="#top" title="{{ macros_translate::translate(key='go_to_top', default='Go to Top', language_strings=language_strings) }}"><i class="icon"></i></a>
	{%- if config.extra.show_share_button -%}
		<a id="share" href="https://shareopenly.org/share/?url={{ page.permalink }}&text={{ page.description | urlencode }}" rel="{{ rel_attributes }}" title="{{ macros_translate::translate(key='share', default='Share', language_strings=language_strings) }}"><i class="icon"></i></a>
	{%- endif -%}
	{%- if config.extra.issues_url -%}
		<a id="issue" href="{{ config.extra.issues_url }}" rel="{{ rel_attributes }}" title="{{ macros_translate::translate(key='file_an_issue', default='File an Issue', language_strings=language_strings) }}"><i class="icon"></i></a>
	{%- endif -%}
</div>
{% endblock content %}
