Support directory installations
- Add web log to HttpContext on first retrieval per req - Add several DotLiquid filters - Use int for page numbers - Update all themes to use rel/abs link and other filters
This commit is contained in:
@@ -289,8 +289,20 @@ module WebLog =
|
||||
timeZone = ""
|
||||
}
|
||||
|
||||
/// Convert a permalink to an absolute URL
|
||||
let absoluteUrl webLog = function Permalink link -> $"{webLog.urlBase}{link}"
|
||||
/// Get the host (including scheme) and extra path from the URL base
|
||||
let hostAndPath webLog =
|
||||
let scheme = webLog.urlBase.Split "://"
|
||||
let host = scheme[1].Split "/"
|
||||
$"{scheme[0]}://{host[0]}", if host.Length > 1 then $"""/{String.Join ("/", host |> Array.skip 1)}""" else ""
|
||||
|
||||
/// Generate an absolute URL for the given link
|
||||
let absoluteUrl webLog permalink =
|
||||
$"{webLog.urlBase}/{Permalink.toString permalink}"
|
||||
|
||||
/// Generate a relative URL for the given link
|
||||
let relativeUrl webLog permalink =
|
||||
let _, leadPath = hostAndPath webLog
|
||||
$"{leadPath}/{Permalink.toString permalink}"
|
||||
|
||||
/// Convert a date/time to the web log's local date/time
|
||||
let localTime webLog (date : DateTime) =
|
||||
|
||||
@@ -400,7 +400,8 @@ type PostListItem =
|
||||
|
||||
/// Create a post list item from a post
|
||||
static member fromPost (webLog : WebLog) (post : Post) =
|
||||
let inTZ = WebLog.localTime webLog
|
||||
let _, extra = WebLog.hostAndPath webLog
|
||||
let inTZ = WebLog.localTime webLog
|
||||
{ id = PostId.toString post.id
|
||||
authorId = WebLogUserId.toString post.authorId
|
||||
status = PostStatus.toString post.status
|
||||
@@ -408,7 +409,7 @@ type PostListItem =
|
||||
permalink = Permalink.toString post.permalink
|
||||
publishedOn = post.publishedOn |> Option.map inTZ |> Option.toNullable
|
||||
updatedOn = inTZ post.updatedOn
|
||||
text = post.text
|
||||
text = if extra = "" then post.text else post.text.Replace ("href=\"/", $"href=\"{extra}/")
|
||||
categoryIds = post.categoryIds |> List.map CategoryId.toString
|
||||
tags = post.tags
|
||||
meta = post.metadata
|
||||
|
||||
Reference in New Issue
Block a user