Include page body in file generation hook.

This commit is contained in:
Dillon Kearns 2020-01-23 19:23:53 -08:00
parent 2e8fbee58b
commit 29d9fa39cb
6 changed files with 31 additions and 0 deletions

View File

@ -18,6 +18,7 @@ fileToGenerate :
List
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
, body : String
}
->
{ path : List String
@ -38,6 +39,7 @@ generate :
List
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
, body : String
}
-> Xml.Value
generate { siteTagline, siteUrl } siteMetadata =
@ -55,6 +57,7 @@ generate { siteTagline, siteUrl } siteMetadata =
metadataToRssItem :
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
, body : String
}
-> Maybe RssFeed.Item
metadataToRssItem page =

View File

@ -74,6 +74,7 @@ generateFiles :
List
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
, body : String
}
->
List

View File

@ -18,6 +18,7 @@ build :
List
{ path : PagePath Pages.PathKey
, frontmatter : Metadata
, body : String
}
->
{ path : List String

View File

@ -501,6 +501,7 @@ application :
List
{ path : PagePath pathKey
, frontmatter : metadata
, body : String
}
->
List
@ -578,6 +579,7 @@ cliApplication :
List
{ path : PagePath pathKey
, frontmatter : metadata
, body : String
}
->
List

View File

@ -173,6 +173,7 @@ type alias Config pathKey userMsg userModel metadata view =
List
{ path : PagePath pathKey
, frontmatter : metadata
, body : String
}
->
List
@ -769,8 +770,30 @@ sendStaticResponsesIfDone config siteMetadata mode secrets allRawResponses error
|> Result.withDefault []
|> List.map
(\( pagePath, metadata ) ->
let
contentForPage =
config.content
|> List.filterMap
(\( path, { body } ) ->
let
pagePathToGenerate =
PagePath.toString pagePath
currentContentPath =
"/" ++ (path |> String.join "/")
in
if pagePathToGenerate == currentContentPath then
Just body
else
Nothing
)
|> List.head
|> Maybe.andThen identity
in
{ path = pagePath
, frontmatter = metadata
, body = contentForPage |> Maybe.withDefault ""
}
)
|> config.generateFiles

View File

@ -81,6 +81,7 @@ application :
List
{ path : PagePath pathKey
, frontmatter : metadata
, body : String
}
->
List