No more PathKey for PagePath!

This commit is contained in:
Dillon Kearns 2021-04-10 10:33:26 -07:00
parent ca901b043d
commit 12b36d964f
29 changed files with 214 additions and 215 deletions

View File

@ -28,7 +28,7 @@ blogPostsGlob =
|> Glob.toStaticHttp |> Glob.toStaticHttp
allMetadata : StaticHttp.Request (List ( PagePath Pages.PathKey, ArticleMetadata )) allMetadata : StaticHttp.Request (List ( PagePath, ArticleMetadata ))
allMetadata = allMetadata =
--StaticFile.glob "content/blog/*.md" --StaticFile.glob "content/blog/*.md"
blogPostsGlob blogPostsGlob

View File

@ -9,7 +9,7 @@ import Palette
view : view :
PagePath Pages.PathKey PagePath
-> Element msg -> Element msg
view currentPage = view currentPage =
Element.column Element.column
@ -38,7 +38,7 @@ view currentPage =
postSummary : postSummary :
( Bool, PagePath Pages.PathKey, { title : String } ) ( Bool, PagePath, { title : String } )
-> Element msg -> Element msg
postSummary ( isCurrentPage, postPath, post ) = postSummary ( isCurrentPage, postPath, post ) =
[ Element.text post.title ] [ Element.text post.title ]
@ -60,7 +60,7 @@ postSummary ( isCurrentPage, postPath, post ) =
|> linkToPost postPath |> linkToPost postPath
linkToPost : PagePath Pages.PathKey -> Element msg -> Element msg linkToPost : PagePath -> Element msg -> Element msg
linkToPost postPath content = linkToPost postPath content =
Element.link [ Element.width Element.fill ] Element.link [ Element.width Element.fill ]
{ url = PagePath.toString postPath, label = content } { url = PagePath.toString postPath, label = content }

View File

@ -12,7 +12,7 @@ fileToGenerate :
} }
-> ->
List List
{ path : PagePath Pages.PathKey { path : PagePath
, frontmatter : Metadata , frontmatter : Metadata
, body : String , body : String
} }
@ -32,7 +32,7 @@ generate :
} }
-> ->
List List
{ path : PagePath Pages.PathKey { path : PagePath
, frontmatter : Metadata , frontmatter : Metadata
, body : String , body : String
} }
@ -50,7 +50,7 @@ generate { siteTagline, siteUrl } siteMetadata =
metadataToRssItem : metadataToRssItem :
{ path : PagePath Pages.PathKey { path : PagePath
, frontmatter : Metadata , frontmatter : Metadata
, body : String , body : String
} }

View File

@ -12,7 +12,7 @@ import Pages.PagePath as PagePath exposing (PagePath)
view : view :
List ( PagePath Pages.PathKey, Article.ArticleMetadata ) List ( PagePath, Article.ArticleMetadata )
-> Element msg -> Element msg
view posts = view posts =
Element.column [ Element.spacing 20 ] Element.column [ Element.spacing 20 ]
@ -24,7 +24,7 @@ view posts =
postSummary : postSummary :
( PagePath Pages.PathKey, Article.ArticleMetadata ) ( PagePath, Article.ArticleMetadata )
-> Element msg -> Element msg
postSummary ( path, post ) = postSummary ( path, post ) =
articleIndex post |> linkToPost path articleIndex post |> linkToPost path
@ -34,7 +34,7 @@ postSummary ( path, post ) =
-- postPath -- postPath
linkToPost : PagePath Pages.PathKey -> Element msg -> Element msg linkToPost : PagePath -> Element msg -> Element msg
linkToPost postPath content = linkToPost postPath content =
Element.link [ Element.width Element.fill ] Element.link [ Element.width Element.fill ]
{ url = PagePath.toString postPath, label = content } { url = PagePath.toString postPath, label = content }

View File

@ -13,7 +13,7 @@ generate :
, siteUrl : String , siteUrl : String
, title : String , title : String
, builtAt : Time.Posix , builtAt : Time.Posix
, indexPage : PagePath pathKey , indexPage : PagePath
} }
-> (item -> Maybe Rss.Item) -> (item -> Maybe Rss.Item)
-> StaticHttp.Request (List item) -> StaticHttp.Request (List item)

View File

@ -25,7 +25,7 @@ type alias SharedTemplate route templateDemuxMsg msg1 msg2 =
{ init : { init :
Maybe Maybe
{ path : { path :
{ path : PagePath Pages.PathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -36,7 +36,7 @@ type alias SharedTemplate route templateDemuxMsg msg1 msg2 =
, view : , view :
StaticData StaticData
-> ->
{ path : PagePath Pages.PathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
-> Model -> Model
@ -45,10 +45,10 @@ type alias SharedTemplate route templateDemuxMsg msg1 msg2 =
-> { body : Html templateDemuxMsg, title : String } -> { body : Html templateDemuxMsg, title : String }
, map : (msg1 -> msg2) -> PageView msg1 -> PageView msg2 , map : (msg1 -> msg2) -> PageView msg1 -> PageView msg2
, staticData : StaticHttp.Request StaticData , staticData : StaticHttp.Request StaticData
, subscriptions : NoMetadata -> PagePath Pages.PathKey -> Model -> Sub Msg , subscriptions : NoMetadata -> PagePath -> Model -> Sub Msg
, onPageChange : , onPageChange :
Maybe Maybe
({ path : PagePath Pages.PathKey ({ path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -75,7 +75,7 @@ type alias PageView msg =
type Msg type Msg
= OnPageChange = OnPageChange
{ path : PagePath Pages.PathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -108,7 +108,7 @@ map fn doc =
init : init :
Maybe Maybe
{ path : { path :
{ path : PagePath Pages.PathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -141,7 +141,7 @@ update msg model =
( { model | counter = model.counter + 1 }, Cmd.none ) ( { model | counter = model.counter + 1 }, Cmd.none )
subscriptions : NoMetadata -> PagePath Pages.PathKey -> Model -> Sub Msg subscriptions : NoMetadata -> PagePath -> Model -> Sub Msg
subscriptions _ _ _ = subscriptions _ _ _ =
Sub.none Sub.none
@ -155,7 +155,7 @@ staticData =
view : view :
StaticData StaticData
-> ->
{ path : PagePath Pages.PathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
-> Model -> Model
@ -223,7 +223,7 @@ navbarLinks stars currentPath =
] ]
header : Int -> PagePath Pages.PathKey -> Element Msg header : Int -> PagePath -> Element Msg
header stars currentPath = header stars currentPath =
Element.column [ Element.width Element.fill ] Element.column [ Element.width Element.fill ]
[ responsiveHeader [ responsiveHeader
@ -316,7 +316,7 @@ elmDocsLink =
highlightableLink : highlightableLink :
PagePath Pages.PathKey PagePath
-> Directory Pages.PathKey Directory.WithIndex -> Directory Pages.PathKey Directory.WithIndex
-> String -> String
-> Element msg -> Element msg

View File

@ -36,7 +36,7 @@ type alias StaticData =
} }
config : SiteConfig StaticData Pages.PathKey config : SiteConfig StaticData
config = config =
{ staticData = staticData { staticData = staticData
, canonicalUrl = canonicalUrl , canonicalUrl = canonicalUrl
@ -67,7 +67,7 @@ canonicalUrl static =
"https://elm-pages.com" "https://elm-pages.com"
manifest : StaticData -> Manifest.Config Pages.PathKey manifest : StaticData -> Manifest.Config
manifest static = manifest static =
{ backgroundColor = Just Color.white { backgroundColor = Just Color.white
, categories = [ Pages.Manifest.Category.education ] , categories = [ Pages.Manifest.Category.education ]

View File

@ -41,7 +41,7 @@ staticData =
type alias StaticData = type alias StaticData =
List ( PagePath Pages.PathKey, Article.ArticleMetadata ) List ( PagePath, Article.ArticleMetadata )
init : {} -> ( Model, Cmd Msg ) init : {} -> ( Model, Cmd Msg )

View File

@ -127,7 +127,7 @@ counterView sharedModel =
Element.el [ Element.Events.onClick Increment ] (Element.text <| "Docs count: " ++ String.fromInt sharedModel.counter) Element.el [ Element.Events.onClick Increment ] (Element.text <| "Docs count: " ++ String.fromInt sharedModel.counter)
tocView : PagePath Pages.PathKey -> MarkdownRenderer.TableOfContents -> Element msg tocView : PagePath -> MarkdownRenderer.TableOfContents -> Element msg
tocView path toc = tocView path toc =
Element.column [ Element.alignTop, Element.spacing 20 ] Element.column [ Element.alignTop, Element.spacing 20 ]
[ Element.el [ Font.bold, Font.size 22 ] (Element.text "Table of Contents") [ Element.el [ Font.bold, Font.size 22 ] (Element.text "Table of Contents")

View File

@ -9,10 +9,10 @@ import TemplateType
template : template :
{ staticData : { staticData :
List ( PagePath Pages.PathKey, TemplateType.Metadata ) List ( PagePath, TemplateType.Metadata )
-> StaticHttp.Request staticData -> StaticHttp.Request staticData
, view : , view :
List ( PagePath Pages.PathKey, TemplateType.Metadata ) List ( PagePath, TemplateType.Metadata )
-> staticData -> staticData
-> model -> model
-> metadata -> metadata
@ -20,7 +20,7 @@ template :
-> view -> view
, head : , head :
staticData staticData
-> PagePath Pages.PathKey -> PagePath
-> metadata -> metadata
-> List (Head.Tag Pages.PathKey) -> List (Head.Tag Pages.PathKey)
, init : metadata -> ( model, Cmd templateMsg ) , init : metadata -> ( model, Cmd templateMsg )
@ -33,10 +33,10 @@ template config =
type alias Template metadata renderedTemplate staticData model view templateMsg = type alias Template metadata renderedTemplate staticData model view templateMsg =
{ staticData : { staticData :
List ( PagePath Pages.PathKey, TemplateType.Metadata ) List ( PagePath, TemplateType.Metadata )
-> StaticHttp.Request staticData -> StaticHttp.Request staticData
, view : , view :
List ( PagePath Pages.PathKey, TemplateType.Metadata ) List ( PagePath, TemplateType.Metadata )
-> staticData -> staticData
-> model -> model
-> metadata -> metadata
@ -44,7 +44,7 @@ type alias Template metadata renderedTemplate staticData model view templateMsg
-> view -> view
, head : , head :
staticData staticData
-> PagePath Pages.PathKey -> PagePath
-> metadata -> metadata
-> List (Head.Tag Pages.PathKey) -> List (Head.Tag Pages.PathKey)
, init : metadata -> ( model, Cmd templateMsg ) , init : metadata -> ( model, Cmd templateMsg )

View File

@ -65,7 +65,7 @@ type alias TemplateWithState routeParams templateStaticData templateModel templa
-> List (Head.Tag Pages.PathKey) -> List (Head.Tag Pages.PathKey)
, init : routeParams -> ( templateModel, Cmd templateMsg ) , init : routeParams -> ( templateModel, Cmd templateMsg )
, update : routeParams -> templateMsg -> templateModel -> Shared.Model -> ( templateModel, Cmd templateMsg, Maybe Shared.SharedMsg ) , update : routeParams -> templateMsg -> templateModel -> Shared.Model -> ( templateModel, Cmd templateMsg, Maybe Shared.SharedMsg )
, subscriptions : routeParams -> PagePath Pages.PathKey -> templateModel -> Shared.Model -> Sub templateMsg , subscriptions : routeParams -> PagePath -> templateModel -> Shared.Model -> Sub templateMsg
} }
@ -79,7 +79,7 @@ type alias StaticPayload staticData routeParams =
{ static : staticData -- local { static : staticData -- local
, sharedStatic : Shared.StaticData -- share , sharedStatic : Shared.StaticData -- share
, routeParams : routeParams , routeParams : routeParams
, path : PagePath Pages.PathKey , path : PagePath
} }
@ -124,7 +124,7 @@ buildWithLocalState :
-> Shared.PageView templateMsg -> Shared.PageView templateMsg
, init : routeParams -> ( templateModel, Cmd templateMsg ) , init : routeParams -> ( templateModel, Cmd templateMsg )
, update : Shared.Model -> routeParams -> templateMsg -> templateModel -> ( templateModel, Cmd templateMsg ) , update : Shared.Model -> routeParams -> templateMsg -> templateModel -> ( templateModel, Cmd templateMsg )
, subscriptions : routeParams -> PagePath Pages.PathKey -> templateModel -> Sub templateMsg , subscriptions : routeParams -> PagePath -> templateModel -> Sub templateMsg
} }
-> Builder routeParams templateStaticData -> Builder routeParams templateStaticData
-> TemplateWithState routeParams templateStaticData templateModel templateMsg -> TemplateWithState routeParams templateStaticData templateModel templateMsg
@ -160,7 +160,7 @@ buildWithSharedState :
-> Shared.PageView templateMsg -> Shared.PageView templateMsg
, init : routeParams -> ( templateModel, Cmd templateMsg ) , init : routeParams -> ( templateModel, Cmd templateMsg )
, update : routeParams -> templateMsg -> templateModel -> Shared.Model -> ( templateModel, Cmd templateMsg, Maybe Shared.SharedMsg ) , update : routeParams -> templateMsg -> templateModel -> Shared.Model -> ( templateModel, Cmd templateMsg, Maybe Shared.SharedMsg )
, subscriptions : routeParams -> PagePath Pages.PathKey -> templateModel -> Shared.Model -> Sub templateMsg , subscriptions : routeParams -> PagePath -> templateModel -> Shared.Model -> Sub templateMsg
} }
-> Builder routeParams templateStaticData -> Builder routeParams templateStaticData
-> TemplateWithState routeParams templateStaticData templateModel templateMsg -> TemplateWithState routeParams templateStaticData templateModel templateMsg

View File

@ -69,12 +69,12 @@ type alias PathKey
= () = ()
buildImage : List String -> ImagePath PathKey buildImage : List String -> ImagePath ()
buildImage path = buildImage path =
ImagePath.build () ("images" :: path) ImagePath.build () ("images" :: path)
buildPage : List String -> PagePath PathKey buildPage : List String -> PagePath
buildPage path = buildPage path =
PagePath.build path PagePath.build path
@ -136,12 +136,12 @@ type alias PathKey
= () = ()
buildImage : List String -> ImagePath PathKey buildImage : List String -> ImagePath ()
buildImage path = buildImage path =
ImagePath.build () ("images" :: path) ImagePath.build () ("images" :: path)
buildPage : List String -> PagePath PathKey buildPage : List String -> PagePath
buildPage path = buildPage path =
PagePath.build path PagePath.build path

View File

@ -210,7 +210,7 @@ function captureRouteRecord(pieces, elmType, record) {
function formatAsElmList(name, items) { function formatAsElmList(name, items) {
var formatted = items.join("\n , "); var formatted = items.join("\n , ");
var signature = name + " : List (PagePath PathKey)\n"; var signature = name + " : List PagePath\n";
return signature + name + " =\n [ " + formatted + "\n ]"; return signature + name + " =\n [ " + formatted + "\n ]";
} }

View File

@ -41,7 +41,7 @@ type alias Model =
, current : , current :
Maybe Maybe
{ path : { path :
{ path : PagePath Pages.PathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -94,7 +94,7 @@ routes =
type Msg type Msg
= MsgGlobal Shared.Msg = MsgGlobal Shared.Msg
| OnPageChange | OnPageChange
{ path : PagePath Pages.PathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
, metadata : Maybe Route , metadata : Maybe Route
@ -108,13 +108,13 @@ type Msg
view : view :
{ path : PagePath Pages.PathKey { path : PagePath
, frontmatter : Maybe Route , frontmatter : Maybe Route
} }
-> ->
StaticHttp.Request StaticHttp.Request
{ view : Model -> { title : String, body : Html Msg } { view : Model -> { title : String, body : Html Msg }
, head : List (Head.Tag Pages.PathKey) , head : List (Head.Tag ())
} }
view page = view page =
case page.frontmatter of case page.frontmatter of
@ -173,7 +173,7 @@ init :
-> ->
Maybe Maybe
{ path : { path :
{ path : PagePath Pages.PathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -304,10 +304,10 @@ update msg model =
type alias SiteConfig = type alias SiteConfig =
{ canonicalUrl : String { canonicalUrl : String
, manifest : Manifest.Config Pages.PathKey , manifest : Manifest.Config
} }
templateSubscriptions : Route -> PagePath Pages.PathKey -> Model -> Sub Msg templateSubscriptions : Route -> PagePath -> Model -> Sub Msg
templateSubscriptions route path model = templateSubscriptions route path model =
case ( model.page, route ) of case ( model.page, route ) of
${templates ${templates
@ -331,7 +331,7 @@ templateSubscriptions route path model =
Sub.none Sub.none
main : Pages.Internal.Platform.Program Model Msg (Maybe Route) Pages.PathKey main : Pages.Internal.Platform.Program Model Msg (Maybe Route)
main = main =
Pages.Internal.Platform.${ Pages.Internal.Platform.${
phase === "browser" ? "application" : "cliApplication" phase === "browser" ? "application" : "cliApplication"
@ -376,7 +376,7 @@ main =
, toJsPort = Pages.internals.toJsPort , toJsPort = Pages.internals.toJsPort
, fromJsPort = Pages.internals.fromJsPort , fromJsPort = Pages.internals.fromJsPort
, generateFiles = Site.config.generateFiles , generateFiles = Site.config.generateFiles
, pathKey = Pages.internals.pathKey , pathKey = ()
} }

View File

@ -98,7 +98,7 @@ type alias StaticData =
Int Int
view : List ( PagePath Pages.PathKey, TemplateType.Metadata ) -> StaticData -> Model -> BlogPost -> ( a, List (Element msg) ) -> { title : String, body : Element msg } view : List ( PagePath, TemplateType.Metadata ) -> StaticData -> Model -> BlogPost -> ( a, List (Element msg) ) -> { title : String, body : Element msg }
view allMetadata static model blogPost rendered = view allMetadata static model blogPost rendered =
{ title = blogPost.title { title = blogPost.title
, body = , body =
@ -131,7 +131,7 @@ view allMetadata static model blogPost rendered =
} }
head : StaticData -> PagePath.PagePath Pages.PathKey -> BlogPost -> List (Head.Tag Pages.PathKey) head : StaticData -> PagePath.PagePath -> BlogPost -> List (Head.Tag Pages.PathKey)
head static currentPath meta = head static currentPath meta =
Head.structuredData Head.structuredData
(StructuredData.article (StructuredData.article

View File

@ -174,7 +174,7 @@ fullImageUrl value =
{-| Create an `AttributeValue` from a `PagePath`. {-| Create an `AttributeValue` from a `PagePath`.
-} -}
fullPageUrl : PagePath pathKey -> AttributeValue pathKey fullPageUrl : PagePath -> AttributeValue pathKey
fullPageUrl value = fullPageUrl value =
FullUrl (PagePath.toString value) FullUrl (PagePath.toString value)
@ -208,7 +208,7 @@ Example:
Head.canonicalLink "https://elm-pages.com" Head.canonicalLink "https://elm-pages.com"
-} -}
canonicalLink : Maybe (PagePath pathKey) -> Tag pathKey canonicalLink : Maybe PagePath -> Tag pathKey
canonicalLink maybePath = canonicalLink maybePath =
node "link" node "link"
[ ( "rel", raw "canonical" ) [ ( "rel", raw "canonical" )

View File

@ -65,7 +65,7 @@ If you want one of those, use `audioPlayer` or `videoPlayer`
-} -}
summaryLarge : summaryLarge :
{ canonicalUrlOverride : Maybe (PagePath pathKey) { canonicalUrlOverride : Maybe PagePath
, siteName : String , siteName : String
, image : Image pathKey , image : Image pathKey
, description : String , description : String
@ -87,7 +87,7 @@ If you want one of those, use `audioPlayer` or `videoPlayer`
-} -}
summary : summary :
{ canonicalUrlOverride : Maybe (PagePath pathKey) { canonicalUrlOverride : Maybe PagePath
, siteName : String , siteName : String
, image : Image pathKey , image : Image pathKey
, description : String , description : String
@ -107,7 +107,7 @@ The options will also be used to build up the appropriate OpenGraph `<meta>` tag
-} -}
audioPlayer : audioPlayer :
{ canonicalUrlOverride : Maybe (PagePath pathKey) { canonicalUrlOverride : Maybe PagePath
, siteName : String , siteName : String
, image : Image pathKey , image : Image pathKey
, description : String , description : String
@ -150,7 +150,7 @@ The options will also be used to build up the appropriate OpenGraph `<meta>` tag
-} -}
videoPlayer : videoPlayer :
{ canonicalUrlOverride : Maybe (PagePath pathKey) { canonicalUrlOverride : Maybe PagePath
, siteName : String , siteName : String
, image : Image pathKey , image : Image pathKey
, description : String , description : String
@ -186,7 +186,7 @@ videoPlayer { title, image, canonicalUrlOverride, description, siteName, video,
buildSummary : buildSummary :
{ canonicalUrlOverride : Maybe (PagePath pathKey) { canonicalUrlOverride : Maybe PagePath
, siteName : String , siteName : String
, image : Image pathKey , image : Image pathKey
, description : String , description : String
@ -297,7 +297,7 @@ Skipping this for now, if there's a use case I can add it in:
type alias Common pathKey = type alias Common pathKey =
{ title : String { title : String
, image : Image pathKey , image : Image pathKey
, canonicalUrlOverride : Maybe (PagePath pathKey) , canonicalUrlOverride : Maybe PagePath
, description : String , description : String
, siteName : String , siteName : String
, audio : Maybe Audio , audio : Maybe Audio

View File

@ -227,7 +227,7 @@ lookup :
pathKey pathKey
-> ContentCache -> ContentCache
-> { currentUrl : Url, baseUrl : Url } -> { currentUrl : Url, baseUrl : Url }
-> Maybe ( PagePath pathKey, Entry ) -> Maybe ( PagePath, Entry )
lookup _ content urls = lookup _ content urls =
case content of case content of
Ok dict -> Ok dict ->
@ -250,7 +250,7 @@ lookupMetadata :
pathKey pathKey
-> ContentCache -> ContentCache
-> { currentUrl : Url, baseUrl : Url } -> { currentUrl : Url, baseUrl : Url }
-> Maybe (PagePath pathKey) -> Maybe PagePath
lookupMetadata pathKey content urls = lookupMetadata pathKey content urls =
urls urls
|> lookup pathKey content |> lookup pathKey content

View File

@ -38,7 +38,7 @@ import Pages.PagePath as PagePath exposing (PagePath)
of your `elm-pages` site. of your `elm-pages` site.
-} -}
type Directory key hasIndex type Directory key hasIndex
= Directory key (List (PagePath key)) (List String) = Directory key (List PagePath) (List String)
{-| Used for a `Directory` that has an index path directly at that path. See {-| Used for a `Directory` that has an index path directly at that path. See
@ -64,7 +64,7 @@ your generated `Pages.elm` module).
import Element.Font as Font import Element.Font as Font
import Pages.Directory as Directory exposing (Directory) import Pages.Directory as Directory exposing (Directory)
navbar : PagePath Pages.PathKey -> Element msg navbar : PagePath -> Element msg
navbar currentPage = navbar currentPage =
Element.row [ Element.spacing 15 ] Element.row [ Element.spacing 15 ]
[ navbarLink currentPath pages.docs.directory "Docs" [ navbarLink currentPath pages.docs.directory "Docs"
@ -72,7 +72,7 @@ your generated `Pages.elm` module).
] ]
navbarLink : navbarLink :
PagePath Pages.PathKey PagePath
-> Directory Pages.PathKey Directory.WithIndex -> Directory Pages.PathKey Directory.WithIndex
-> String -> String
-> Element msg -> Element msg
@ -95,8 +95,8 @@ your generated `Pages.elm` module).
} }
-} -}
includes : Directory key hasIndex -> PagePath key -> Bool includes : Directory key hasIndex -> PagePath -> Bool
includes (Directory key allPagePaths directoryPath) pagePath = includes (Directory _ allPagePaths directoryPath) pagePath =
allPagePaths allPagePaths
|> List.filter |> List.filter
(\path -> (\path ->
@ -121,22 +121,22 @@ includes (Directory key allPagePaths directoryPath) pagePath =
See `Directory.includes` for an example of this in action. See `Directory.includes` for an example of this in action.
-} -}
indexPath : Directory key WithIndex -> PagePath key indexPath : Directory key WithIndex -> PagePath
indexPath (Directory key allPagePaths directoryPath) = indexPath (Directory _ _ directoryPath) =
PagePath.build directoryPath PagePath.build directoryPath
{-| Get the path of the directory as a String. Same as `directory |> Directory.basePath |> String.join "/"`. {-| Get the path of the directory as a String. Same as `directory |> Directory.basePath |> String.join "/"`.
-} -}
basePathToString : Directory key hasIndex -> String basePathToString : Directory key hasIndex -> String
basePathToString (Directory key allPagePaths directoryPath) = basePathToString (Directory _ _ directoryPath) =
toString directoryPath toString directoryPath
{-| Gives you the parts of the path of the directory. {-| Gives you the parts of the path of the directory.
-} -}
basePath : Directory key hasIndex -> List String basePath : Directory key hasIndex -> List String
basePath (Directory key allPagePaths directoryPath) = basePath (Directory _ _ directoryPath) =
directoryPath directoryPath
@ -148,7 +148,7 @@ toString =
{-| Used by the generated `Pages.elm` module. There's no need to use this {-| Used by the generated `Pages.elm` module. There's no need to use this
outside of the generated code. outside of the generated code.
-} -}
withIndex : key -> List (PagePath key) -> List String -> Directory key WithIndex withIndex : key -> List PagePath -> List String -> Directory key WithIndex
withIndex key allPagePaths path = withIndex key allPagePaths path =
Directory key allPagePaths path Directory key allPagePaths path
@ -156,6 +156,6 @@ withIndex key allPagePaths path =
{-| Used by the generated `Pages.elm` module. There's no need to use this {-| Used by the generated `Pages.elm` module. There's no need to use this
outside of the generated code. outside of the generated code.
-} -}
withoutIndex : key -> List (PagePath key) -> List String -> Directory key WithoutIndex withoutIndex : key -> List PagePath -> List String -> Directory key WithoutIndex
withoutIndex key allPagePaths path = withoutIndex key allPagePaths path =
Directory key allPagePaths path Directory key allPagePaths path

View File

@ -24,17 +24,17 @@ import Task
import Url exposing (Url) import Url exposing (Url)
type alias Program userModel userMsg route pathKey = type alias Program userModel userMsg route =
Platform.Program Flags (Model userModel route pathKey) (Msg userMsg) Platform.Program Flags (Model userModel route) (Msg userMsg)
mainView : mainView :
(Url -> route) (Url -> route)
-> pathKey -> pathKey
-> ->
(List ( PagePath pathKey, NoMetadata ) (List ( PagePath, NoMetadata )
-> ->
{ path : PagePath pathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
-> ->
@ -54,8 +54,8 @@ mainView urlToRoute pathKey pageView model =
pageViewOrError urlToRoute pathKey pageView model model.contentCache pageViewOrError urlToRoute pathKey pageView model model.contentCache
urlToPagePath : pathKey -> Url -> Url -> PagePath pathKey urlToPagePath : Url -> Url -> PagePath
urlToPagePath pathKey url baseUrl = urlToPagePath url baseUrl =
url.path url.path
|> String.dropLeft (String.length baseUrl.path) |> String.dropLeft (String.length baseUrl.path)
|> String.chopForwardSlashes |> String.chopForwardSlashes
@ -68,9 +68,9 @@ pageViewOrError :
(Url -> route) (Url -> route)
-> pathKey -> pathKey
-> ->
(List ( PagePath pathKey, NoMetadata ) (List ( PagePath, NoMetadata )
-> ->
{ path : PagePath pathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
-> ->
@ -152,9 +152,9 @@ view :
(Url -> route) (Url -> route)
-> pathKey -> pathKey
-> ->
(List ( PagePath pathKey, NoMetadata ) (List ( PagePath, NoMetadata )
-> ->
{ path : PagePath pathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
-> ->
@ -212,7 +212,7 @@ init :
(Maybe (Maybe
{ metadata : route { metadata : route
, path : , path :
{ path : PagePath pathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -368,9 +368,9 @@ type AppMsg userMsg
| StartingHotReload | StartingHotReload
type Model userModel route pathKey type Model userModel route
= Model (ModelDetails userModel) = Model (ModelDetails userModel)
| CliModel (Pages.Internal.Platform.Cli.Model pathKey route) | CliModel (Pages.Internal.Platform.Cli.Model route)
type alias ModelDetails userModel = type alias ModelDetails userModel =
@ -394,9 +394,9 @@ update :
-> List String -> List String
-> String -> String
-> ->
(List ( PagePath pathKey, NoMetadata ) (List ( PagePath, NoMetadata )
-> ->
{ path : PagePath pathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
-> ->
@ -408,7 +408,7 @@ update :
-> pathKey -> pathKey
-> ->
Maybe Maybe
({ path : PagePath pathKey ({ path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
, metadata : route , metadata : route
@ -420,7 +420,7 @@ update :
-> Msg userMsg -> Msg userMsg
-> ModelDetails userModel -> ModelDetails userModel
-> ( ModelDetails userModel, Cmd (AppMsg userMsg) ) -> ( ModelDetails userModel, Cmd (AppMsg userMsg) )
update urlToRoute allRoutes canonicalSiteUrl viewFunction pathKey maybeOnPageChangeMsg toJsPort userUpdate msg model = update urlToRoute allRoutes canonicalSiteUrl viewFunction _ maybeOnPageChangeMsg toJsPort userUpdate msg model =
case msg of case msg of
AppMsg appMsg -> AppMsg appMsg ->
case appMsg of case appMsg of
@ -486,7 +486,7 @@ update urlToRoute allRoutes canonicalSiteUrl viewFunction pathKey maybeOnPageCha
} }
maybeCmd = maybeCmd =
case ContentCache.lookup pathKey updatedCache urls of case ContentCache.lookup () updatedCache urls of
Just ( pagePath, entry ) -> Just ( pagePath, entry ) ->
case entry of case entry of
ContentCache.Parsed viewResult -> ContentCache.Parsed viewResult ->
@ -531,7 +531,7 @@ update urlToRoute allRoutes canonicalSiteUrl viewFunction pathKey maybeOnPageCha
Just onPageChangeMsg -> Just onPageChangeMsg ->
userUpdate userUpdate
(onPageChangeMsg (onPageChangeMsg
{ path = urlToPagePath pathKey url model.baseUrl { path = urlToPagePath url model.baseUrl
, query = url.query , query = url.query
, fragment = url.fragment , fragment = url.fragment
, metadata = urlToRoute url , metadata = urlToRoute url
@ -583,7 +583,7 @@ application :
{ init : { init :
Maybe Maybe
{ path : { path :
{ path : PagePath pathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -593,23 +593,23 @@ application :
, urlToRoute : Url -> route , urlToRoute : Url -> route
, routeToPath : route -> List String , routeToPath : route -> List String
, getStaticRoutes : StaticHttp.Request (List route) , getStaticRoutes : StaticHttp.Request (List route)
, site : SiteConfig staticData pathKey , site : SiteConfig staticData
, update : userMsg -> userModel -> ( userModel, Cmd userMsg ) , update : userMsg -> userModel -> ( userModel, Cmd userMsg )
, subscriptions : NoMetadata -> PagePath pathKey -> userModel -> Sub userMsg , subscriptions : NoMetadata -> PagePath -> userModel -> Sub userMsg
, view : , view :
List ( PagePath pathKey, NoMetadata ) List ( PagePath, NoMetadata )
-> ->
{ path : PagePath pathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
-> ->
StaticHttp.Request StaticHttp.Request
{ view : userModel -> { title : String, body : Html userMsg } { view : userModel -> { title : String, body : Html userMsg }
, head : List (Head.Tag pathKey) , head : List (Head.Tag ())
} }
, toJsPort : Json.Encode.Value -> Cmd Never , toJsPort : Json.Encode.Value -> Cmd Never
, fromJsPort : Sub Decode.Value , fromJsPort : Sub Decode.Value
, manifest : Manifest.Config pathKey , manifest : Manifest.Config
, generateFiles : , generateFiles :
StaticHttp.Request StaticHttp.Request
(List (List
@ -624,7 +624,7 @@ application :
, pathKey : pathKey , pathKey : pathKey
, onPageChange : , onPageChange :
Maybe Maybe
({ path : PagePath pathKey ({ path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
, metadata : route , metadata : route
@ -633,7 +633,7 @@ application :
) )
} }
-- -> Program userModel userMsg metadata view -- -> Program userModel userMsg metadata view
-> Platform.Program Flags (Model userModel route pathKey) (Msg userMsg) -> Platform.Program Flags (Model userModel route) (Msg userMsg)
application config = application config =
Browser.application Browser.application
{ init = { init =
@ -645,7 +645,7 @@ application config =
\outerModel -> \outerModel ->
case outerModel of case outerModel of
Model model -> Model model ->
view config.urlToRoute config.pathKey config.view model view config.urlToRoute () config.view model
CliModel _ -> CliModel _ ->
{ title = "Error" { title = "Error"
@ -674,7 +674,7 @@ application config =
|> List.map Tuple.first |> List.map Tuple.first
|> List.map (String.join "/") |> List.map (String.join "/")
in in
update config.urlToRoute allRoutes config.canonicalSiteUrl config.view config.pathKey config.onPageChange config.toJsPort userUpdate msg model update config.urlToRoute allRoutes config.canonicalSiteUrl config.view () config.onPageChange config.toJsPort userUpdate msg model
|> Tuple.mapFirst Model |> Tuple.mapFirst Model
|> Tuple.mapSecond (Cmd.map AppMsg) |> Tuple.mapSecond (Cmd.map AppMsg)
@ -737,7 +737,7 @@ cliApplication :
{ init : { init :
Maybe Maybe
{ path : { path :
{ path : PagePath pathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -748,22 +748,22 @@ cliApplication :
, routeToPath : route -> List String , routeToPath : route -> List String
, getStaticRoutes : StaticHttp.Request (List route) , getStaticRoutes : StaticHttp.Request (List route)
, update : userMsg -> userModel -> ( userModel, Cmd userMsg ) , update : userMsg -> userModel -> ( userModel, Cmd userMsg )
, subscriptions : NoMetadata -> PagePath pathKey -> userModel -> Sub userMsg , subscriptions : NoMetadata -> PagePath -> userModel -> Sub userMsg
, site : SiteConfig staticData pathKey , site : SiteConfig staticData
, view : , view :
List ( PagePath pathKey, NoMetadata ) List ( PagePath, NoMetadata )
-> ->
{ path : PagePath pathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
-> ->
StaticHttp.Request StaticHttp.Request
{ view : userModel -> { title : String, body : Html userMsg } { view : userModel -> { title : String, body : Html userMsg }
, head : List (Head.Tag pathKey) , head : List (Head.Tag ())
} }
, toJsPort : Json.Encode.Value -> Cmd Never , toJsPort : Json.Encode.Value -> Cmd Never
, fromJsPort : Sub Decode.Value , fromJsPort : Sub Decode.Value
, manifest : Manifest.Config pathKey , manifest : Manifest.Config
, generateFiles : , generateFiles :
StaticHttp.Request StaticHttp.Request
(List (List
@ -775,10 +775,10 @@ cliApplication :
) )
) )
, canonicalSiteUrl : String , canonicalSiteUrl : String
, pathKey : pathKey , pathKey : ()
, onPageChange : , onPageChange :
Maybe Maybe
({ path : PagePath pathKey ({ path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
, metadata : route , metadata : route
@ -786,7 +786,7 @@ cliApplication :
-> userMsg -> userMsg
) )
} }
-> Program userModel userMsg route pathKey -> Program userModel userMsg route
cliApplication = cliApplication =
Pages.Internal.Platform.Cli.cliApplication CliMsg Pages.Internal.Platform.Cli.cliApplication CliMsg
(\msg -> (\msg ->

View File

@ -43,15 +43,15 @@ type alias Flags =
Decode.Value Decode.Value
type alias Model pathKey route = type alias Model route =
{ staticResponses : StaticResponses { staticResponses : StaticResponses
, secrets : SecretsDict , secrets : SecretsDict
, errors : List BuildError , errors : List BuildError
, allRawResponses : Dict String (Maybe String) , allRawResponses : Dict String (Maybe String)
, mode : Mode , mode : Mode
, pendingRequests : List { masked : RequestDetails, unmasked : RequestDetails } , pendingRequests : List { masked : RequestDetails, unmasked : RequestDetails }
, unprocessedPages : List ( PagePath pathKey, route ) , unprocessedPages : List ( PagePath, route )
, staticRoutes : List ( PagePath pathKey, route ) , staticRoutes : List ( PagePath, route )
, maybeRequestJson : Maybe Decode.Value , maybeRequestJson : Maybe Decode.Value
} }
@ -63,11 +63,11 @@ type Msg
| Continue | Continue
type alias Config pathKey userMsg userModel route siteStaticData = type alias Config userMsg userModel route siteStaticData =
{ init : { init :
Maybe Maybe
{ path : { path :
{ path : PagePath pathKey { path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
} }
@ -77,23 +77,23 @@ type alias Config pathKey userMsg userModel route siteStaticData =
, getStaticRoutes : StaticHttp.Request (List route) , getStaticRoutes : StaticHttp.Request (List route)
, urlToRoute : Url -> route , urlToRoute : Url -> route
, routeToPath : route -> List String , routeToPath : route -> List String
, site : SiteConfig siteStaticData pathKey , site : SiteConfig siteStaticData
, update : userMsg -> userModel -> ( userModel, Cmd userMsg ) , update : userMsg -> userModel -> ( userModel, Cmd userMsg )
, subscriptions : NoMetadata -> PagePath pathKey -> userModel -> Sub userMsg , subscriptions : NoMetadata -> PagePath -> userModel -> Sub userMsg
, view : , view :
List ( PagePath pathKey, NoMetadata ) List ( PagePath, NoMetadata )
-> ->
{ path : PagePath pathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
-> ->
StaticHttp.Request StaticHttp.Request
{ view : userModel -> { title : String, body : Html userMsg } { view : userModel -> { title : String, body : Html userMsg }
, head : List (Head.Tag pathKey) , head : List (Head.Tag ())
} }
, toJsPort : Json.Encode.Value -> Cmd Never , toJsPort : Json.Encode.Value -> Cmd Never
, fromJsPort : Sub Decode.Value , fromJsPort : Sub Decode.Value
, manifest : Manifest.Config pathKey , manifest : Manifest.Config
, generateFiles : , generateFiles :
StaticHttp.Request StaticHttp.Request
(List (List
@ -105,10 +105,10 @@ type alias Config pathKey userMsg userModel route siteStaticData =
) )
) )
, canonicalSiteUrl : String , canonicalSiteUrl : String
, pathKey : pathKey , pathKey : ()
, onPageChange : , onPageChange :
Maybe Maybe
({ path : PagePath pathKey ({ path : PagePath
, query : Maybe String , query : Maybe String
, fragment : Maybe String , fragment : Maybe String
, metadata : route , metadata : route
@ -121,9 +121,9 @@ type alias Config pathKey userMsg userModel route siteStaticData =
cliApplication : cliApplication :
(Msg -> msg) (Msg -> msg)
-> (msg -> Maybe Msg) -> (msg -> Maybe Msg)
-> (Model pathKey route -> model) -> (Model route -> model)
-> (model -> Maybe (Model pathKey route)) -> (model -> Maybe (Model route))
-> Config pathKey userMsg userModel route siteStaticData -> Config userMsg userModel route siteStaticData
-> Platform.Program Flags model msg -> Platform.Program Flags model msg
cliApplication cliMsgConstructor narrowMsg toModel fromModel config = cliApplication cliMsgConstructor narrowMsg toModel fromModel config =
let let
@ -227,7 +227,7 @@ asJsonView x =
Json.Encode.string "REPLACE_ME_WITH_JSON_STRINGIFY" Json.Encode.string "REPLACE_ME_WITH_JSON_STRINGIFY"
perform : Maybe Decode.Value -> Config pathKey userMsg userModel route siteStaticData -> (Msg -> msg) -> (Json.Encode.Value -> Cmd Never) -> Effect pathKey -> Cmd msg perform : Maybe Decode.Value -> Config userMsg userModel route siteStaticData -> (Msg -> msg) -> (Json.Encode.Value -> Cmd Never) -> Effect -> Cmd msg
perform maybeRequest config cliMsgConstructor toJsPort effect = perform maybeRequest config cliMsgConstructor toJsPort effect =
case effect of case effect of
Effect.NoEffect -> Effect.NoEffect ->
@ -376,11 +376,11 @@ flagsDecoder =
init : init :
Maybe Decode.Value Maybe Decode.Value
-> (Model pathKey route -> model) -> (Model route -> model)
-> ContentCache -> ContentCache
-> Config pathKey userMsg userModel route siteStaticData -> Config userMsg userModel route siteStaticData
-> Decode.Value -> Decode.Value
-> ( model, Effect pathKey ) -> ( model, Effect )
init maybeRequestJson toModel contentCache config flags = init maybeRequestJson toModel contentCache config flags =
case Decode.decodeValue flagsDecoder flags of case Decode.decodeValue flagsDecoder flags of
Ok { secrets, mode, staticHttpCache } -> Ok { secrets, mode, staticHttpCache } ->
@ -418,15 +418,15 @@ init maybeRequestJson toModel contentCache config flags =
--) --)
type alias RequestPayload route pathKey = type alias RequestPayload route =
{ path : PagePath pathKey { path : PagePath
, frontmatter : route , frontmatter : route
} }
requestPayloadDecoder : requestPayloadDecoder :
Config pathKey userMsg userModel route siteStaticData Config userMsg userModel route siteStaticData
-> Decode.Decoder (Maybe (RequestPayload route pathKey)) -> Decode.Decoder (Maybe (RequestPayload route))
requestPayloadDecoder config = requestPayloadDecoder config =
optionalField "request" optionalField "request"
(Decode.field "path" (Decode.field "path"
@ -476,11 +476,11 @@ optionalField fieldName decoder =
initLegacy : initLegacy :
Maybe Decode.Value Maybe Decode.Value
-> { a | secrets : SecretsDict, mode : Mode, staticHttpCache : Dict String (Maybe String) } -> { a | secrets : SecretsDict, mode : Mode, staticHttpCache : Dict String (Maybe String) }
-> (Model pathKey route -> model) -> (Model route -> model)
-> ContentCache -> ContentCache
-> Config pathKey userMsg userModel route siteStaticData -> Config userMsg userModel route siteStaticData
-> Decode.Value -> Decode.Value
-> ( model, Effect pathKey ) -> ( model, Effect )
initLegacy maybeRequestJson { secrets, mode, staticHttpCache } toModel contentCache config flags = initLegacy maybeRequestJson { secrets, mode, staticHttpCache } toModel contentCache config flags =
let let
maybeRequestPayload = maybeRequestPayload =
@ -524,10 +524,10 @@ initLegacy maybeRequestJson { secrets, mode, staticHttpCache } toModel contentCa
updateAndSendPortIfDone : updateAndSendPortIfDone :
ContentCache ContentCache
-> Config pathKey userMsg userModel route siteStaticData -> Config userMsg userModel route siteStaticData
-> Model pathKey route -> Model route
-> (Model pathKey route -> model) -> (Model route -> model)
-> ( model, Effect pathKey ) -> ( model, Effect )
updateAndSendPortIfDone contentCache config model toModel = updateAndSendPortIfDone contentCache config model toModel =
StaticResponses.nextStep StaticResponses.nextStep
config config
@ -547,10 +547,10 @@ updateAndSendPortIfDone contentCache config model toModel =
update : update :
ContentCache ContentCache
-> Config pathKey userMsg userModel route siteStaticData -> Config userMsg userModel route siteStaticData
-> Msg -> Msg
-> Model pathKey route -> Model route
-> ( Model pathKey route, Effect pathKey ) -> ( Model route, Effect )
update contentCache config msg model = update contentCache config msg model =
case msg of case msg of
GotStaticHttpResponse { request, response } -> GotStaticHttpResponse { request, response } ->
@ -721,10 +721,10 @@ update contentCache config msg model =
nextStepToEffect : nextStepToEffect :
ContentCache ContentCache
-> Config pathKey userMsg userModel route siteStaticData -> Config userMsg userModel route siteStaticData
-> Model pathKey route -> Model route
-> ( StaticResponses, StaticResponses.NextStep pathKey route ) -> ( StaticResponses, StaticResponses.NextStep route )
-> ( Model pathKey route, Effect pathKey ) -> ( Model route, Effect )
nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextStep ) = nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextStep ) =
case nextStep of case nextStep of
StaticResponses.Continue updatedAllRawResponses httpRequests maybeRoutes -> StaticResponses.Continue updatedAllRawResponses httpRequests maybeRoutes ->
@ -825,12 +825,12 @@ nextStepToEffect contentCache config model ( updatedStaticResponsesModel, nextSt
sendSinglePageProgress : sendSinglePageProgress :
ToJsSuccessPayload pathKey ToJsSuccessPayload
-> Config pathKey userMsg userModel route siteStaticData -> Config userMsg userModel route siteStaticData
-> ContentCache -> ContentCache
-> Model pathKey route -> Model route
-> ( PagePath pathKey, route ) -> ( PagePath, route )
-> Effect pathKey -> Effect
sendSinglePageProgress toJsPayload config _ model = sendSinglePageProgress toJsPayload config _ model =
\( page, _ ) -> \( page, _ ) ->
let let
@ -849,16 +849,16 @@ sendSinglePageProgress toJsPayload config _ model =
{ view : { view :
userModel userModel
-> { title : String, body : Html userMsg } -> { title : String, body : Html userMsg }
, head : List (Head.Tag pathKey) , head : List (Head.Tag ())
} }
viewRequest = viewRequest =
config.view [] currentPage config.view [] currentPage
twoThings : Result BuildError { view : userModel -> { title : String, body : Html userMsg }, head : List (Head.Tag pathKey) } twoThings : Result BuildError { view : userModel -> { title : String, body : Html userMsg }, head : List (Head.Tag ()) }
twoThings = twoThings =
viewRequest |> makeItWork viewRequest |> makeItWork
currentPage : { path : PagePath pathKey, frontmatter : route } currentPage : { path : PagePath, frontmatter : route }
currentPage = currentPage =
{ path = page, frontmatter = config.urlToRoute currentUrl } { path = page, frontmatter = config.urlToRoute currentUrl }
@ -915,7 +915,7 @@ popProcessedRequest model =
{ model | unprocessedPages = List.drop 1 model.unprocessedPages } { model | unprocessedPages = List.drop 1 model.unprocessedPages }
sendProgress : ToJsPayload.ToJsSuccessPayloadNew pathKey -> Effect pathKey sendProgress : ToJsPayload.ToJsSuccessPayloadNew -> Effect
sendProgress singlePage = sendProgress singlePage =
Effect.Batch Effect.Batch
[ singlePage |> ToJsPayload.PageProgress |> Effect.SendSinglePage [ singlePage |> ToJsPayload.PageProgress |> Effect.SendSinglePage

View File

@ -4,12 +4,12 @@ import Pages.Internal.Platform.ToJsPayload exposing (ToJsPayload, ToJsSuccessPay
import Pages.StaticHttp exposing (RequestDetails) import Pages.StaticHttp exposing (RequestDetails)
type Effect pathKey type Effect
= NoEffect = NoEffect
| SendJsData (ToJsPayload pathKey) | SendJsData ToJsPayload
| FetchHttp { masked : RequestDetails, unmasked : RequestDetails } | FetchHttp { masked : RequestDetails, unmasked : RequestDetails }
| ReadFile String | ReadFile String
| GetGlob String | GetGlob String
| Batch (List (Effect pathKey)) | Batch (List Effect)
| SendSinglePage (ToJsSuccessPayloadNewCombined pathKey) | SendSinglePage ToJsSuccessPayloadNewCombined
| Continue | Continue

View File

@ -35,9 +35,9 @@ error =
init : init :
{ config { config
| view : List a -> { path : PagePath pathKey, frontmatter : route } -> StaticHttp.Request b | view : List a -> { path : PagePath, frontmatter : route } -> StaticHttp.Request b
, getStaticRoutes : StaticHttp.Request (List route) , getStaticRoutes : StaticHttp.Request (List route)
, site : SiteConfig siteStaticData pathKey , site : SiteConfig siteStaticData
, generateFiles : , generateFiles :
StaticHttp.Request StaticHttp.Request
(List (List
@ -63,10 +63,10 @@ init config =
renderSingleRoute : renderSingleRoute :
{ config { config
| view : List a -> { path : PagePath pathKey, frontmatter : route } -> StaticHttp.Request b | view : List a -> { path : PagePath, frontmatter : route } -> StaticHttp.Request b
, routeToPath : route -> List String , routeToPath : route -> List String
} }
-> { path : PagePath pathKey, frontmatter : route } -> { path : PagePath, frontmatter : route }
-> StaticResponses -> StaticResponses
renderSingleRoute config pathAndRoute = renderSingleRoute config pathAndRoute =
[ pathAndRoute.frontmatter ] [ pathAndRoute.frontmatter ]
@ -142,19 +142,18 @@ cliDictKey =
"////elm-pages-CLI////" "////elm-pages-CLI////"
type NextStep pathKey route type NextStep route
= Continue (Dict String (Maybe String)) (List { masked : RequestDetails, unmasked : RequestDetails }) (Maybe (List route)) = Continue (Dict String (Maybe String)) (List { masked : RequestDetails, unmasked : RequestDetails }) (Maybe (List route))
| Finish (ToJsPayload pathKey) | Finish ToJsPayload
nextStep : nextStep :
{ config { config
| manifest : Manifest.Config pathKey | manifest : Manifest.Config
, getStaticRoutes : StaticHttp.Request (List route) , getStaticRoutes : StaticHttp.Request (List route)
, routeToPath : route -> List String , routeToPath : route -> List String
, view : List a -> { path : PagePath pathKey, frontmatter : route } -> StaticHttp.Request b , view : List a -> { path : PagePath, frontmatter : route } -> StaticHttp.Request b
, site : SiteConfig siteStaticData pathKey , site : SiteConfig siteStaticData
, pathKey : pathKey
, generateFiles : , generateFiles :
StaticHttp.Request StaticHttp.Request
(List (List
@ -172,7 +171,7 @@ nextStep :
-> List BuildError -> List BuildError
-> StaticResponses -> StaticResponses
-> Maybe (List route) -> Maybe (List route)
-> ( StaticResponses, NextStep pathKey route ) -> ( StaticResponses, NextStep route )
nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes = nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes =
let let
staticResponses = staticResponses =

View File

@ -11,26 +11,26 @@ import Pages.Manifest as Manifest
import Pages.PagePath as PagePath import Pages.PagePath as PagePath
type ToJsPayload pathKey type ToJsPayload
= Errors (List BuildError) = Errors (List BuildError)
| Success (ToJsSuccessPayload pathKey) | Success ToJsSuccessPayload
type alias ToJsSuccessPayload pathKey = type alias ToJsSuccessPayload =
{ pages : Dict String (Dict String String) { pages : Dict String (Dict String String)
, manifest : Manifest.Config pathKey , manifest : Manifest.Config
, filesToGenerate : List FileToGenerate , filesToGenerate : List FileToGenerate
, staticHttpCache : Dict String String , staticHttpCache : Dict String String
, errors : List BuildError , errors : List BuildError
} }
type alias ToJsSuccessPayloadNew pathKey = type alias ToJsSuccessPayloadNew =
{ route : String { route : String
, html : String , html : String
, contentJson : Dict String String , contentJson : Dict String String
, errors : List String , errors : List String
, head : List (Head.Tag pathKey) , head : List (Head.Tag ())
, body : String , body : String
, title : String , title : String
, staticHttpCache : Dict String String , staticHttpCache : Dict String String
@ -45,11 +45,11 @@ type alias FileToGenerate =
toJsPayload : toJsPayload :
Dict String (Dict String String) Dict String (Dict String String)
-> Manifest.Config pathKey -> Manifest.Config
-> List FileToGenerate -> List FileToGenerate
-> Dict String (Maybe String) -> Dict String (Maybe String)
-> List BuildError -> List BuildError
-> ToJsPayload pathKey -> ToJsPayload
toJsPayload encodedStatic manifest generated allRawResponses allErrors = toJsPayload encodedStatic manifest generated allRawResponses allErrors =
if allErrors |> List.filter .fatal |> List.isEmpty then if allErrors |> List.filter .fatal |> List.isEmpty then
Success Success
@ -73,7 +73,7 @@ toJsPayload encodedStatic manifest generated allRawResponses allErrors =
Errors <| allErrors Errors <| allErrors
toJsCodec : String -> Codec (ToJsPayload pathKey) toJsCodec : String -> Codec ToJsPayload
toJsCodec canonicalSiteUrl = toJsCodec canonicalSiteUrl =
Codec.custom Codec.custom
(\errorsTag success value -> (\errorsTag success value ->
@ -115,7 +115,7 @@ errorCodec =
|> Codec.buildObject |> Codec.buildObject
stubManifest : Manifest.Config pathKey stubManifest : Manifest.Config
stubManifest = stubManifest =
{ backgroundColor = Nothing { backgroundColor = Nothing
, categories = [] , categories = []
@ -132,7 +132,7 @@ stubManifest =
} }
successCodec : String -> Codec (ToJsSuccessPayload pathKey) successCodec : String -> Codec ToJsSuccessPayload
successCodec canonicalSiteUrl = successCodec canonicalSiteUrl =
Codec.object ToJsSuccessPayload Codec.object ToJsSuccessPayload
|> Codec.field "pages" |> Codec.field "pages"
@ -168,7 +168,7 @@ successCodec canonicalSiteUrl =
|> Codec.buildObject |> Codec.buildObject
successCodecNew : String -> String -> Codec (ToJsSuccessPayloadNew pathKey) successCodecNew : String -> String -> Codec ToJsSuccessPayloadNew
successCodecNew canonicalSiteUrl currentPagePath = successCodecNew canonicalSiteUrl currentPagePath =
Codec.object ToJsSuccessPayloadNew Codec.object ToJsSuccessPayloadNew
|> Codec.field "route" |> Codec.field "route"
@ -196,20 +196,20 @@ headCodec canonicalSiteUrl currentPagePath =
(Decode.succeed (Head.canonicalLink Nothing)) (Decode.succeed (Head.canonicalLink Nothing))
type ToJsSuccessPayloadNewCombined pathKey type ToJsSuccessPayloadNewCombined
= PageProgress (ToJsSuccessPayloadNew pathKey) = PageProgress ToJsSuccessPayloadNew
| InitialData (InitialDataRecord pathKey) | InitialData InitialDataRecord
| ReadFile String | ReadFile String
| Glob String | Glob String
type alias InitialDataRecord pathKey = type alias InitialDataRecord =
{ filesToGenerate : List FileToGenerate { filesToGenerate : List FileToGenerate
, manifest : Manifest.Config pathKey , manifest : Manifest.Config
} }
successCodecNew2 : String -> String -> Codec (ToJsSuccessPayloadNewCombined pathKey) successCodecNew2 : String -> String -> Codec ToJsSuccessPayloadNewCombined
successCodecNew2 canonicalSiteUrl currentPagePath = successCodecNew2 canonicalSiteUrl currentPagePath =
Codec.custom Codec.custom
(\success initialData vReadFile vGlob value -> (\success initialData vReadFile vGlob value ->
@ -233,7 +233,7 @@ successCodecNew2 canonicalSiteUrl currentPagePath =
|> Codec.buildCustom |> Codec.buildCustom
manifestCodec : String -> Codec (Manifest.Config pathKey) manifestCodec : String -> Codec Manifest.Config
manifestCodec canonicalSiteUrl = manifestCodec canonicalSiteUrl =
Codec.build (Manifest.toJson canonicalSiteUrl) (Decode.succeed stubManifest) Codec.build (Manifest.toJson canonicalSiteUrl) (Decode.succeed stubManifest)
@ -259,7 +259,7 @@ filesToGenerateCodec =
) )
initialDataCodec : String -> Codec (InitialDataRecord pathKey) initialDataCodec : String -> Codec InitialDataRecord
initialDataCodec canonicalSiteUrl = initialDataCodec canonicalSiteUrl =
Codec.object InitialDataRecord Codec.object InitialDataRecord
|> Codec.field "filesToGenerate" |> Codec.field "filesToGenerate"

View File

@ -144,7 +144,7 @@ known static resources for any internal image or page paths.
are present (not broken images). are present (not broken images).
-} -}
type alias Config pathKey = type alias Config =
{ backgroundColor : Maybe Color { backgroundColor : Maybe Color
, categories : List Category , categories : List Category
, displayMode : DisplayMode , displayMode : DisplayMode
@ -155,12 +155,12 @@ type alias Config pathKey =
, themeColor : Maybe Color , themeColor : Maybe Color
-- https://developer.mozilla.org/en-US/docs/Web/Manifest/start_url -- https://developer.mozilla.org/en-US/docs/Web/Manifest/start_url
, startUrl : PagePath pathKey , startUrl : PagePath
-- https://developer.mozilla.org/en-US/docs/Web/Manifest/short_name -- https://developer.mozilla.org/en-US/docs/Web/Manifest/short_name
, shortName : Maybe String , shortName : Maybe String
, sourceIcon : ImagePath pathKey , sourceIcon : ImagePath ()
, icons : List (Icon pathKey) , icons : List (Icon ())
} }
@ -247,7 +247,7 @@ nonEmptyList list =
{-| Feel free to use this, but in 99% of cases you won't need it. The generated {-| Feel free to use this, but in 99% of cases you won't need it. The generated
code will run this for you to generate your `manifest.json` file automatically! code will run this for you to generate your `manifest.json` file automatically!
-} -}
toJson : String -> Config pathKey -> Encode.Value toJson : String -> Config -> Encode.Value
toJson canonicalSiteUrl config = toJson canonicalSiteUrl config =
[ ( "sourceIcon" [ ( "sourceIcon"
, config.sourceIcon , config.sourceIcon

View File

@ -21,7 +21,7 @@ two ways:
You will find a list of all the pages in your app in this generated code: You will find a list of all the pages in your app in this generated code:
Pages.allPages : List (PagePath Pages.PathKey) Pages.allPages : List (PagePath)
This is handy for creating an index page, for example showing all This is handy for creating an index page, for example showing all
the blog posts in your site. the blog posts in your site.
@ -38,7 +38,7 @@ This gives you a record, based on your local `content` directory, that lets you
import Pages import Pages
import Pages.PagePath as PagePath exposing (PagePath) import Pages.PagePath as PagePath exposing (PagePath)
homePath : PagePath Pages.PathKey homePath : PagePath
homePath = homePath =
Pages.pages.index Pages.pages.index
@ -50,7 +50,7 @@ or
import Pages import Pages
import Pages.PagePath as PagePath exposing (PagePath) import Pages.PagePath as PagePath exposing (PagePath)
helloWorldPostPath : PagePath Pages.PathKey helloWorldPostPath : PagePath
helloWorldPostPath = helloWorldPostPath =
Pages.pages.blog.helloWorld Pages.pages.blog.helloWorld
@ -87,7 +87,7 @@ So `PagePath` represents either a 1) known, static page path, or 2) an
external page path (which is not validated so use these carefully!). external page path (which is not validated so use these carefully!).
-} -}
type PagePath key type PagePath
= Internal (List String) = Internal (List String)
| External String | External String
@ -101,7 +101,7 @@ type PagePath key
-- `Pages` is a generated module -- `Pages` is a generated module
homePath : PagePath Pages.PathKey homePath : PagePath
homePath = homePath =
Pages.pages.index Pages.pages.index
@ -110,7 +110,7 @@ type PagePath key
a [ href (PagePath.toString homePath) ] [ text "🏡 Home" ] a [ href (PagePath.toString homePath) ] [ text "🏡 Home" ]
-} -}
toString : PagePath key -> String toString : PagePath -> String
toString path = toString path =
case path of case path of
Internal rawPath -> Internal rawPath ->
@ -129,7 +129,7 @@ toString path =
PagePath.toPath Pages.pages.blog.hello == [ "blog", "hello" ] PagePath.toPath Pages.pages.blog.hello == [ "blog", "hello" ]
-} -}
toPath : PagePath key -> List String toPath : PagePath -> List String
toPath path = toPath path =
case path of case path of
Internal rawPath -> Internal rawPath ->
@ -152,18 +152,18 @@ this only to point to outside pages.
-- with `Pages.PathKey`, since external links are always valid -- with `Pages.PathKey`, since external links are always valid
-- (unlike internal routes, which are guaranteed to be present -- (unlike internal routes, which are guaranteed to be present
-- if your code compiles). -- if your code compiles).
googlePath : PagePath Pages.PathKey googlePath : PagePath
googlePath = googlePath =
PagePath.external "https://google.com" PagePath.external "https://google.com"
-} -}
external : String -> PagePath key external : String -> PagePath
external url = external url =
External url External url
{-| This is not useful except for the internal generated code to construct a PagePath. {-| This is not useful except for the internal generated code to construct a PagePath.
-} -}
build : List String -> PagePath key build : List String -> PagePath
build path = build path =
Internal path Internal path

View File

@ -5,13 +5,13 @@ import Pages.Manifest
import Pages.StaticHttp as StaticHttp import Pages.StaticHttp as StaticHttp
type alias SiteConfig staticData pathKey = type alias SiteConfig staticData =
{ staticData : StaticHttp.Request staticData { staticData : StaticHttp.Request staticData
, canonicalUrl : staticData -> String , canonicalUrl : staticData -> String
, manifest : staticData -> Pages.Manifest.Config pathKey , manifest : staticData -> Pages.Manifest.Config
, head : , head :
staticData staticData
-> List (Head.Tag pathKey) -> List (Head.Tag ())
, generateFiles : , generateFiles :
StaticHttp.Request StaticHttp.Request
(List (List

View File

@ -389,9 +389,9 @@ andThen fn requestInfo =
import Pages.StaticHttp as StaticHttp import Pages.StaticHttp as StaticHttp
view : view :
List ( PagePath Pages.PathKey, Metadata ) List ( PagePath, Metadata )
-> ->
{ path : PagePath Pages.PathKey { path : PagePath
, frontmatter : Metadata , frontmatter : Metadata
} }
-> ->

View File

@ -906,7 +906,7 @@ startLowLevel generateFiles documentBodyResult staticHttpCache pages =
{- {-
(Model -> model) (Model -> model)
-> ContentCache.ContentCache metadata view -> ContentCache.ContentCache metadata view
-> Result (List BuildError) (List ( PagePath pathKey, metadata )) -> Result (List BuildError) (List ( PagePath, metadata ))
-> Config pathKey userMsg userModel metadata view -> Config pathKey userMsg userModel metadata view
-> Decode.Value -> Decode.Value
-> ( model, Effect pathKey ) -> ( model, Effect pathKey )