diff --git a/OliverBooth/Controllers/BlogApiController.cs b/OliverBooth/Controllers/BlogApiController.cs index b2d361b..b134f86 100644 --- a/OliverBooth/Controllers/BlogApiController.cs +++ b/OliverBooth/Controllers/BlogApiController.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Mvc; +using Humanizer; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; using OliverBooth.Data.Blog; using OliverBooth.Services; @@ -43,6 +44,7 @@ public sealed class BlogApiController : ControllerBase title = post.Title, published = post.Published.ToUnixTimeSeconds(), updated = post.Updated?.ToUnixTimeSeconds(), + humanizedTimestamp = post.Updated?.Humanize() ?? post.Published.Humanize(), excerpt = _blogService.GetExcerpt(post, out bool trimmed), trimmed, url = Url.Page("/Blog/Article", diff --git a/src/ts/BlogPost.ts b/src/ts/BlogPost.ts index d077cb4..fe7f0e6 100644 --- a/src/ts/BlogPost.ts +++ b/src/ts/BlogPost.ts @@ -9,6 +9,7 @@ private readonly _url: string; private readonly _trimmed: boolean; private readonly _identifier: string; + private readonly _humanizedTimestamp: string; constructor(json: any) { this._id = json.id; @@ -21,6 +22,7 @@ this._url = json.url; this._trimmed = json.trimmed; this._identifier = json.identifier; + this._humanizedTimestamp = json.humanizedTimestamp; } get id(): number { @@ -62,6 +64,10 @@ get identifier(): string { return this._identifier; } + + get humanizedTimestamp(): string { + return this._humanizedTimestamp; + } } export default BlogPost; \ No newline at end of file