Improve post template handling of dates and authors

This commit is contained in:
Christian Reitter 2023-12-02 16:50:25 +01:00
parent 3e5813df85
commit 062152cd76
1 changed files with 12 additions and 10 deletions

View File

@ -7,18 +7,20 @@ layout: default
<h1 class="post-title p-name" itemprop="name headline">{{ page.title | escape }}</h1>
<p class="post-meta">
{%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%}
<time class="dt-published" datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">
{{ page.date | date: date_format }}
</time>
{%- if page.modified_date -%}
~
{%- assign mdate = page.modified_date | date_to_xmlschema -%}
<time class="dt-modified" datetime="{{ mdate }}" itemprop="dateModified">
{{ mdate | date: date_format }}
</time>
<time class="dt-published" datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">Published: {{ page.date | date: date_format }}</time></br>
{%- if page.last_modified_at -%}
{%- assign mdate = page.last_modified_at | date_to_xmlschema -%}
<time class="dt-modified" datetime="{{ mdate }}" itemprop="dateModified">Updated: {{ mdate | date: date_format }}</time>
{%- endif -%}
</br>
{%- if page.author -%}
Author(s): {% for author in page.author -%}
{% for author in page.author -%}{%- assign author_count = author_count | plus: 1 -%}{% endfor %}
{%- if author_count==1 -%}
Author
{%- else -%}
Authors
{%- endif -%}
: {% for author in page.author -%}
<span itemprop="author" itemscope itemtype="http://schema.org/Person"><span class="p-author h-card" itemprop="name">{{ author }}</span></span>
{%- if forloop.last == false %}, {% endif -%}
{% endfor %}