Add all categories to post render context

- Convert post date/time to web log timezone
This commit is contained in:
2022-04-26 22:24:17 -04:00
parent ff87a71c9c
commit 6e7f4cc8ce
8 changed files with 66 additions and 31 deletions

View File

@@ -308,14 +308,16 @@ type PostListItem =
}
/// Create a post list item from a post
static member fromPost (post : Post) =
static member fromPost (webLog : WebLog) (post : Post) =
let tz = TimeZoneInfo.FindSystemTimeZoneById webLog.timeZone
let inTZ (it : DateTime) = TimeZoneInfo.ConvertTimeFromUtc (DateTime (it.Ticks, DateTimeKind.Utc), tz)
{ id = PostId.toString post.id
authorId = WebLogUserId.toString post.authorId
status = PostStatus.toString post.status
title = post.title
permalink = Permalink.toString post.permalink
publishedOn = Option.toNullable post.publishedOn
updatedOn = post.updatedOn
publishedOn = post.publishedOn |> Option.map inTZ |> Option.toNullable
updatedOn = inTZ post.updatedOn
text = post.text
categoryIds = post.categoryIds |> List.map CategoryId.toString
tags = post.tags