pages/_layouts/post.liquid
Tao Deng a29e24a46b
add last updated date to posts (#2341)
This PR is related to #2309. I added an optional `last_updated` field.
This new field represents the timestamp for when the post was last
updated. Consequently, the existing `date` metadata should now be
interpreted as the creation date of the post.

The formatting for displaying these dates has been standardized as
follows:

```text
Created: July 11, 2023   |   Last Updated: April 14, 2024
```

For a practical implementation example, please refer to [this
post](https://torydeng.github.io/blog/2023/deploying-server/) on my
website, where I have applied these changes.

---

Any feedback is wellcome.
2024-04-24 12:19:36 -03:00

92 lines
2.8 KiB
Plaintext

---
layout: default
---
{% assign year = page.date | date: '%Y' %}
{% assign tags = page.tags | join: '' %}
{% assign categories = page.categories | join: '' %}
{% if page._styles %}
<!-- Page/Post style -->
<style type="text/css">
{{ page._styles }}
</style>
{% endif %}
{% assign url_beginning = page.url | slice: 0, 6 %}
<div class="post">
<header class="post-header">
<h1 class="post-title">{{ page.title }}</h1>
<p class="post-meta">
Created in {{ page.date | date: '%B %d, %Y' }}
{% if page.author %}by {{ page.author }}{% endif %}
{% if page.last_updated %}, last updated in {{ page.last_updated | date: '%B %d, %Y' }}{% endif %}
{% if page.meta %}• {{ page.meta }}{% endif %}
</p>
<p class="post-tags">
{% if url_beginning == '/blog/' %}
<a href="{{ year | prepend: '/blog/' | prepend: site.baseurl}}"> <i class="fa-solid fa-calendar fa-sm"></i> {{ year }} </a>
{% else %}
<i class="fa-solid fa-calendar fa-sm"></i> {{ year }}
{% endif %}
{% if tags != '' %}
&nbsp; &middot; &nbsp;
{% for tag in page.tags %}
{% if url_beginning == '/blog/' %}
<a href="{{ tag | slugify | prepend: '/blog/tag/' | prepend: site.baseurl}}"> <i class="fa-solid fa-hashtag fa-sm"></i> {{ tag }}</a>
&nbsp;
{% else %}
<i class="fa-solid fa-hashtag fa-sm"></i> {{ tag }} &nbsp;
{% endif %}
{% endfor %}
{% endif %}
{% if categories != '' %}
&nbsp; &middot; &nbsp;
{% for category in page.categories %}
{% if url_beginning == '/blog/' %}
<a href="{{ category | slugify | prepend: '/blog/category/' | prepend: site.baseurl}}">
<i class="fa-solid fa-tag fa-sm"></i> {{ category -}}
</a>
&nbsp;
{% else %}
<i class="fa-solid fa-tag fa-sm"></i> {{ category }} &nbsp;
{% endif %}
{% endfor %}
{% endif %}
</p>
</header>
<article class="post-content">
{% if page.toc and page.toc.beginning %}
<div id="table-of-contents">
{% toc %}
</div>
<hr>
{% endif %}
<div id="markdown-content">
{{ content }}
</div>
</article>
{% if page.related_publications %}
<h2>References</h2>
<div class="publications">
{% bibliography --cited_in_order %}
</div>
{% endif %}
{% if site.related_blog_posts.enabled %}
{% if page.related_posts == null or page.related_posts %}
{% include related_posts.liquid %}
{% endif %}
{% endif %}
{% if site.disqus_shortname and page.disqus_comments %}
{% include disqus.liquid %}
{% endif %}
{% if site.giscus and page.giscus_comments %}
{% include giscus.liquid %}
{% endif %}
</div>