feat: add pre-formatted date "dddd, d MMMM yyyy HH:mm"
This commit is contained in:
parent
d67955f28a
commit
506347ce9c
|
@ -43,6 +43,7 @@ public sealed class BlogApiController : ControllerBase
|
||||||
author = post.AuthorId,
|
author = post.AuthorId,
|
||||||
title = post.Title,
|
title = post.Title,
|
||||||
published = post.Published.ToUnixTimeSeconds(),
|
published = post.Published.ToUnixTimeSeconds(),
|
||||||
|
formattedDate = post.Published.ToString("dddd, d MMMM yyyy HH:mm"),
|
||||||
updated = post.Updated?.ToUnixTimeSeconds(),
|
updated = post.Updated?.ToUnixTimeSeconds(),
|
||||||
humanizedTimestamp = post.Updated?.Humanize() ?? post.Published.Humanize(),
|
humanizedTimestamp = post.Updated?.Humanize() ?? post.Published.Humanize(),
|
||||||
excerpt = _blogService.GetExcerpt(post, out bool trimmed),
|
excerpt = _blogService.GetExcerpt(post, out bool trimmed),
|
||||||
|
|
|
@ -29,14 +29,14 @@
|
||||||
<img class="blog-author-icon" src="https://gravatar.com/avatar/@author.AvatarHash?s=28" alt="@author.Name">
|
<img class="blog-author-icon" src="https://gravatar.com/avatar/@author.AvatarHash?s=28" alt="@author.Name">
|
||||||
@author.Name •
|
@author.Name •
|
||||||
|
|
||||||
<abbr data-bs-toggle="tooltip" data-bs-title="@published.ToString("f")">
|
<abbr data-bs-toggle="tooltip" data-bs-title="@published.ToString("dddd, d MMMM yyyy HH:mm")">
|
||||||
Published @published.Humanize()
|
Published @published.Humanize()
|
||||||
</abbr>
|
</abbr>
|
||||||
|
|
||||||
@if (post.Updated is { } updated)
|
@if (post.Updated is { } updated)
|
||||||
{
|
{
|
||||||
<span>•</span>
|
<span>•</span>
|
||||||
<abbr data-bs-toggle="tooltip" data-bs-title="@updated.ToString("f")">
|
<abbr data-bs-toggle="tooltip" data-bs-title="@updated.ToString("dddd, d MMMM yyyy HH:mm")">
|
||||||
Updated @updated.Humanize()
|
Updated @updated.Humanize()
|
||||||
</abbr>
|
</abbr>
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<img class="blog-author-icon" src="{{author.avatar}}" alt="{{author.name}}">
|
<img class="blog-author-icon" src="{{author.avatar}}" alt="{{author.name}}">
|
||||||
<span>{{author.name}}<span>
|
<span>{{author.name}}<span>
|
||||||
<span> • </span>
|
<span> • </span>
|
||||||
<span title="{{ post.date }}">{{ post.date_humanized }}</span>
|
<abbr title="{{ post.formattedDate }}">{{ post.date_humanized }}</abbr>
|
||||||
{{#if post.enable_comments}}
|
{{#if post.enable_comments}}
|
||||||
<span> • </span>
|
<span> • </span>
|
||||||
<a href="{{post.url}}#disqus_thread" data-disqus-identifier="{{post.disqus_identifier}}">
|
<a href="{{post.url}}#disqus_thread" data-disqus-identifier="{{post.disqus_identifier}}">
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
private readonly _trimmed: boolean;
|
private readonly _trimmed: boolean;
|
||||||
private readonly _identifier: string;
|
private readonly _identifier: string;
|
||||||
private readonly _humanizedTimestamp: string;
|
private readonly _humanizedTimestamp: string;
|
||||||
|
private readonly _formattedDate: string;
|
||||||
|
|
||||||
constructor(json: any) {
|
constructor(json: any) {
|
||||||
this._id = json.id;
|
this._id = json.id;
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
this._trimmed = json.trimmed;
|
this._trimmed = json.trimmed;
|
||||||
this._identifier = json.identifier;
|
this._identifier = json.identifier;
|
||||||
this._humanizedTimestamp = json.humanizedTimestamp;
|
this._humanizedTimestamp = json.humanizedTimestamp;
|
||||||
|
this._formattedDate = json.formattedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
get id(): number {
|
get id(): number {
|
||||||
|
@ -68,6 +70,10 @@
|
||||||
get humanizedTimestamp(): string {
|
get humanizedTimestamp(): string {
|
||||||
return this._humanizedTimestamp;
|
return this._humanizedTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get formattedDate(): string {
|
||||||
|
return this._formattedDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BlogPost;
|
export default BlogPost;
|
|
@ -27,6 +27,7 @@ declare const Handlebars: any;
|
||||||
excerpt: post.excerpt,
|
excerpt: post.excerpt,
|
||||||
url: post.url,
|
url: post.url,
|
||||||
date: TimeUtility.formatRelativeTimestamp(post.published),
|
date: TimeUtility.formatRelativeTimestamp(post.published),
|
||||||
|
formattedDate: post.formattedDate,
|
||||||
date_humanized: `${post.updated ? "Updated" : "Published"} ${post.humanizedTimestamp}`,
|
date_humanized: `${post.updated ? "Updated" : "Published"} ${post.humanizedTimestamp}`,
|
||||||
enable_comments: post.commentsEnabled,
|
enable_comments: post.commentsEnabled,
|
||||||
disqus_identifier: post.identifier,
|
disqus_identifier: post.identifier,
|
||||||
|
|
Loading…
Reference in New Issue