Add meta item

- Use meta item for category/author lookups
- Add Liquid filter to get values from meta item lists
- Implement log on "returnUrl" parameter
This commit is contained in:
2022-04-24 23:21:22 -04:00
parent d0e016fd28
commit fa20122f20
8 changed files with 96 additions and 32 deletions

View File

@@ -88,6 +88,17 @@ module MarkupText =
| text -> invalidOp $"Cannot derive type of text ({text})"
/// An item of metadata
[<CLIMutable; NoComparison; NoEquality>]
type MetaItem =
{ /// The name of the metadata value
name : string
/// The metadata value
value : string
}
/// A revision of a page or post
[<CLIMutable; NoComparison; NoEquality>]
type Revision =

View File

@@ -209,7 +209,14 @@ type LogOnModel =
/// The user's password
password : string
/// Where the user should be redirected once they have logged on
returnTo : string option
}
/// An empty log on model
static member empty =
{ emailAddress = ""; password = ""; returnTo = None }
/// View model for posts in a list
@@ -221,9 +228,6 @@ type PostListItem =
/// The ID of the user who authored the post
authorId : string
/// The name of the user who authored the post
authorName : string
/// The status of the post
status : string
@@ -243,25 +247,24 @@ type PostListItem =
text : string
/// The IDs of the categories for this post
categoryIds : string[]
categoryIds : string list
/// Tags for the post
tags : string[]
tags : string list
}
/// Create a post list item from a post
static member fromPost (post : Post) =
{ id = PostId.toString post.id
authorId = WebLogUserId.toString post.authorId
authorName = ""
status = PostStatus.toString post.status
title = post.title
permalink = Permalink.toString post.permalink
publishedOn = Option.toNullable post.publishedOn
updatedOn = post.updatedOn
text = post.text
categoryIds = post.categoryIds |> List.map CategoryId.toString |> Array.ofList
tags = Array.ofList post.tags
categoryIds = post.categoryIds |> List.map CategoryId.toString
tags = post.tags
}
@@ -270,8 +273,11 @@ type PostDisplay =
{ /// The posts to be displayed
posts : PostListItem[]
/// Author ID -> name lookup
authors : MetaItem list
/// Category ID -> name lookup
categories : IDictionary<string, string>
categories : MetaItem list
/// A subtitle for the page
subtitle : string option