feat: display Update timestamp if post has been updated

This commit is contained in:
Oliver Booth 2023-08-08 02:06:38 +01:00
parent 84814da85b
commit 6d40452fb3
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61
2 changed files with 13 additions and 4 deletions

View File

@ -29,8 +29,15 @@
@Model.Author?.Name @Model.Author?.Name
• •
<abbr data-bs-toggle="tooltip" data-bs-title="@post.Published.ToString("f")"> <abbr data-bs-toggle="tooltip" data-bs-title="@post.Published.ToString("f")">
@post.Published.Humanize() Published @post.Published.Humanize()
</abbr> </abbr>
@if (post.Updated is { } updated)
{
<span>&bull;</span>
<abbr data-bs-toggle="tooltip" data-bs-title="@updated.ToString("f")">
Updated @updated.Humanize()
</abbr>
}
@if (post.EnableComments) @if (post.EnableComments)
{ {
<span>&bull;</span> <span>&bull;</span>
@ -75,4 +82,4 @@
else else
{ {
<p class="text-center text-muted">Comments are not enabled for this post.</p> <p class="text-center text-muted">Comments are not enabled for this post.</p>
} }

View File

@ -9,6 +9,8 @@
{ {
Author? author = Model.GetAuthor(post); Author? author = Model.GetAuthor(post);
DateTimeOffset published = post.Published; DateTimeOffset published = post.Published;
DateTimeOffset timestamp = post.Updated ?? published;
bool isUpdated = post.Updated.HasValue;
var year = published.ToString("yyyy"); var year = published.ToString("yyyy");
var month = published.ToString("MM"); var month = published.ToString("MM");
var day = published.ToString("dd"); var day = published.ToString("dd");
@ -33,8 +35,8 @@
<img class="blog-author-icon" src="https://gravatar.com/avatar/@author?.AvatarHash?s=28"> <img class="blog-author-icon" src="https://gravatar.com/avatar/@author?.AvatarHash?s=28">
@author?.Name @author?.Name
&bull; &bull;
<abbr data-bs-toggle="tooltip" data-bs-title="@post.Published.ToString("f")"> <abbr data-bs-toggle="tooltip" data-bs-title="@timestamp.ToString("f")">
@post.Published.Humanize() @(isUpdated ? "Updated" : "Published") @timestamp.Humanize()
</abbr> </abbr>
@if (post.EnableComments) @if (post.EnableComments)
{ {