web/_includes/update-list.html
Darian Miller 8da583d403
feat: support hiding the modification date of a post (#1020)
There is the current ability to set `last_modified_at` in the front matter of post and use that datetime instead of the built in logic.
New feature in post.html:  if the modified date time matches the date of the post, then don't show "Updated xxxx"
2023-05-06 11:04:17 +08:00

41 lines
1.2 KiB
HTML

{% comment %}
Get the last 5 posts from lastmod list.
{% endcomment %}
{% assign MAX_SIZE = 5 %}
{% assign all_list = '' | split: '' %}
{% for post in site.posts %}
{% if post.last_modified_at and post.last_modified_at != post.date %}
{% capture elem %}
{{- post.last_modified_at | date: "%Y%m%d%H%M%S" -}}::{{- forloop.index0 -}}
{% endcapture %}
{% assign all_list = all_list | push: elem %}
{% endif %}
{% endfor %}
{% assign all_list = all_list | sort | reverse %}
{% assign update_list = '' | split: '' %}
{% for entry in all_list limit: MAX_SIZE %}
{% assign update_list = update_list | push: entry %}
{% endfor %}
{% if update_list.size > 0 %}
<div id="access-lastmod" class="post">
<div class="panel-heading">{{- site.data.locales[include.lang].panel.lastmod -}}</div>
<ul class="post-content pl-0 pb-1 ml-1 mt-2">
{% for item in update_list %}
{% assign index = item | split: '::' | last | plus: 0 %}
{% assign post = site.posts[index] %}
{% assign url = post.url | relative_url %}
<li>
<a href="{{ url }}">{{ post.title }}</a>
</li>
{% endfor %}
</ul>
</div>
<!-- #access-lastmod -->
{% endif %}