Edited at time

This commit is contained in:
Nathan McCarty 2025-02-05 03:45:01 -05:00
parent 73aefa28eb
commit 7d5cbfba3c
3 changed files with 38 additions and 2 deletions

View file

@ -86,7 +86,7 @@ method site-header(BlogMeta:D $meta) {
method post-date(Post:D $post) {
my $datetime = $post.posted-at;
my $timestamp = sprintf(
"%s %02d:%02d %s",
"%s %02d:%02d%s",
$datetime.yyyy-mm-dd,
($datetime.hour % 12) || 12,
$datetime.minute,
@ -100,6 +100,24 @@ method post-date(Post:D $post) {
]
}
method post-edit(Post:D $post) {
return [] unless $post.edited-at.elems;
my $datetime = $post.edited-at.max;
my $timestamp = sprintf(
"%s %02d:%02d%s",
$datetime.yyyy-mm-dd,
($datetime.hour % 12) || 12,
$datetime.minute,
$datetime.hour < 12 ?? 'am' !! 'pm'
);
div :class<post-edit>, :title("Laste Edited At $timestamp"), [
icon 'edit';
'&nbsp;';
$timestamp
]
}
sub mins-to-string($mins) {
if $mins < 60 {
$mins.Str ~ "m"
@ -130,7 +148,9 @@ method post-read-time(Post:D $post) {
method post-info(Post:D $post) {
div :class<post-info>, [
self.post-date: $post;
self.post-edit: $post;
self.post-read-time: $post;
# TODO: Add tags once we have support for that
];
}
@ -140,7 +160,6 @@ method post-header(Post:D $post) {
h1 $post.title;
];
self.post-info: $post;
# TODO: Add tags once we have support for that
]
}