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
allMetadata : StaticHttp.Request (List ( PagePath Pages.PathKey, ArticleMetadata ))
allMetadata : StaticHttp.Request (List ( PagePath, ArticleMetadata ))
allMetadata =
--StaticFile.glob "content/blog/*.md"
blogPostsGlob

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@ staticData =
type alias StaticData =
List ( PagePath Pages.PathKey, Article.ArticleMetadata )
List ( PagePath, Article.ArticleMetadata )
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)
tocView : PagePath Pages.PathKey -> MarkdownRenderer.TableOfContents -> Element msg
tocView : PagePath -> MarkdownRenderer.TableOfContents -> Element msg
tocView path toc =
Element.column [ Element.alignTop, Element.spacing 20 ]
[ Element.el [ Font.bold, Font.size 22 ] (Element.text "Table of Contents")

View File

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

View File

@ -65,7 +65,7 @@ type alias TemplateWithState routeParams templateStaticData templateModel templa
-> List (Head.Tag Pages.PathKey)
, init : routeParams -> ( templateModel, Cmd templateMsg )
, 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
, sharedStatic : Shared.StaticData -- share
, routeParams : routeParams
, path : PagePath Pages.PathKey
, path : PagePath
}
@ -124,7 +124,7 @@ buildWithLocalState :
-> Shared.PageView templateMsg
, init : routeParams -> ( 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
-> TemplateWithState routeParams templateStaticData templateModel templateMsg
@ -160,7 +160,7 @@ buildWithSharedState :
-> Shared.PageView templateMsg
, init : routeParams -> ( templateModel, Cmd templateMsg )
, 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
-> 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 =
ImagePath.build () ("images" :: path)
buildPage : List String -> PagePath PathKey
buildPage : List String -> PagePath
buildPage path =
PagePath.build path
@ -136,12 +136,12 @@ type alias PathKey
= ()
buildImage : List String -> ImagePath PathKey
buildImage : List String -> ImagePath ()
buildImage path =
ImagePath.build () ("images" :: path)
buildPage : List String -> PagePath PathKey
buildPage : List String -> PagePath
buildPage path =
PagePath.build path

View File

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

View File

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

View File

@ -98,7 +98,7 @@ type alias StaticData =
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 =
{ title = blogPost.title
, 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.structuredData
(StructuredData.article

View File

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

View File

@ -65,7 +65,7 @@ If you want one of those, use `audioPlayer` or `videoPlayer`
-}
summaryLarge :
{ canonicalUrlOverride : Maybe (PagePath pathKey)
{ canonicalUrlOverride : Maybe PagePath
, siteName : String
, image : Image pathKey
, description : String
@ -87,7 +87,7 @@ If you want one of those, use `audioPlayer` or `videoPlayer`
-}
summary :
{ canonicalUrlOverride : Maybe (PagePath pathKey)
{ canonicalUrlOverride : Maybe PagePath
, siteName : String
, image : Image pathKey
, description : String
@ -107,7 +107,7 @@ The options will also be used to build up the appropriate OpenGraph `<meta>` tag
-}
audioPlayer :
{ canonicalUrlOverride : Maybe (PagePath pathKey)
{ canonicalUrlOverride : Maybe PagePath
, siteName : String
, image : Image pathKey
, description : String
@ -150,7 +150,7 @@ The options will also be used to build up the appropriate OpenGraph `<meta>` tag
-}
videoPlayer :
{ canonicalUrlOverride : Maybe (PagePath pathKey)
{ canonicalUrlOverride : Maybe PagePath
, siteName : String
, image : Image pathKey
, description : String
@ -186,7 +186,7 @@ videoPlayer { title, image, canonicalUrlOverride, description, siteName, video,
buildSummary :
{ canonicalUrlOverride : Maybe (PagePath pathKey)
{ canonicalUrlOverride : Maybe PagePath
, siteName : String
, image : Image pathKey
, 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 =
{ title : String
, image : Image pathKey
, canonicalUrlOverride : Maybe (PagePath pathKey)
, canonicalUrlOverride : Maybe PagePath
, description : String
, siteName : String
, audio : Maybe Audio

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -144,7 +144,7 @@ known static resources for any internal image or page paths.
are present (not broken images).
-}
type alias Config pathKey =
type alias Config =
{ backgroundColor : Maybe Color
, categories : List Category
, displayMode : DisplayMode
@ -155,12 +155,12 @@ type alias Config pathKey =
, themeColor : Maybe Color
-- 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
, shortName : Maybe String
, sourceIcon : ImagePath pathKey
, icons : List (Icon pathKey)
, sourceIcon : ImagePath ()
, 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
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 =
[ ( "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:
Pages.allPages : List (PagePath Pages.PathKey)
Pages.allPages : List (PagePath)
This is handy for creating an index page, for example showing all
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.PagePath as PagePath exposing (PagePath)
homePath : PagePath Pages.PathKey
homePath : PagePath
homePath =
Pages.pages.index
@ -50,7 +50,7 @@ or
import Pages
import Pages.PagePath as PagePath exposing (PagePath)
helloWorldPostPath : PagePath Pages.PathKey
helloWorldPostPath : PagePath
helloWorldPostPath =
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!).
-}
type PagePath key
type PagePath
= Internal (List String)
| External String
@ -101,7 +101,7 @@ type PagePath key
-- `Pages` is a generated module
homePath : PagePath Pages.PathKey
homePath : PagePath
homePath =
Pages.pages.index
@ -110,7 +110,7 @@ type PagePath key
a [ href (PagePath.toString homePath) ] [ text "🏡 Home" ]
-}
toString : PagePath key -> String
toString : PagePath -> String
toString path =
case path of
Internal rawPath ->
@ -129,7 +129,7 @@ toString path =
PagePath.toPath Pages.pages.blog.hello == [ "blog", "hello" ]
-}
toPath : PagePath key -> List String
toPath : PagePath -> List String
toPath path =
case path of
Internal rawPath ->
@ -152,18 +152,18 @@ this only to point to outside pages.
-- with `Pages.PathKey`, since external links are always valid
-- (unlike internal routes, which are guaranteed to be present
-- if your code compiles).
googlePath : PagePath Pages.PathKey
googlePath : PagePath
googlePath =
PagePath.external "https://google.com"
-}
external : String -> PagePath key
external : String -> PagePath
external url =
External url
{-| 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 =
Internal path

View File

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

View File

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

View File

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