mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 23:12:22 +03:00
Update generated Pages.elm file template.
This commit is contained in:
parent
575bc0ead5
commit
4b32547c7c
@ -46,26 +46,22 @@ manifest =
|
||||
}
|
||||
|
||||
|
||||
|
||||
--main : Pages.Platform.Program Model Msg (Metadata ) (List (Element Msg))
|
||||
-- the intellij-elm plugin doesn't support type aliases for Programs so we need to use this line
|
||||
|
||||
|
||||
type alias View =
|
||||
( MarkdownRenderer.TableOfContents, List (Element Msg) )
|
||||
|
||||
|
||||
main : Platform.Program Pages.Platform.Flags (Pages.Platform.Model Model Msg Metadata ( MarkdownRenderer.TableOfContents, List (Element Msg) )) (Pages.Platform.Msg Msg Metadata ( MarkdownRenderer.TableOfContents, List (Element Msg) ))
|
||||
main : Pages.Platform.Program Model Msg Metadata View
|
||||
main =
|
||||
Pages.application
|
||||
Pages.Platform.application
|
||||
{ init = init
|
||||
, view = view
|
||||
, update = update
|
||||
, subscriptions = subscriptions
|
||||
, documents = [ markdownDocument ]
|
||||
, manifest = manifest
|
||||
, onPageChange = OnPageChange
|
||||
, canonicalSiteUrl = canonicalSiteUrl
|
||||
, onPageChange = OnPageChange
|
||||
, internals = Pages.internals
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
generateRawContent = require("./generate-raw-content.js");
|
||||
const exposingList =
|
||||
"(PathKey, allPages, allImages, application, images, isValidRoute, pages)";
|
||||
"(PathKey, allPages, allImages, internals, images, isValidRoute, pages)";
|
||||
|
||||
function staticRouteStuff(staticRoutes) {
|
||||
return `
|
||||
@ -44,6 +44,7 @@ function elmPagesUiFile(staticRoutes, markdownContent, markupContent) {
|
||||
return `port module Pages exposing ${exposingList}
|
||||
|
||||
import Color exposing (Color)
|
||||
import Pages.Internal
|
||||
import Head
|
||||
import Html exposing (Html)
|
||||
import Json.Decode
|
||||
@ -90,51 +91,14 @@ directoryWithoutIndex path =
|
||||
port toJsPort : Json.Encode.Value -> Cmd msg
|
||||
|
||||
|
||||
application :
|
||||
{ init : Maybe (PagePath PathKey) -> ( userModel, Cmd userMsg )
|
||||
, update : userMsg -> userModel -> ( userModel, Cmd userMsg )
|
||||
, subscriptions : userModel -> Sub userMsg
|
||||
, view :
|
||||
List ( PagePath PathKey, metadata )
|
||||
->
|
||||
{ path : PagePath PathKey
|
||||
, frontmatter : metadata
|
||||
}
|
||||
->
|
||||
( StaticHttp.Request
|
||||
, Json.Decode.Value
|
||||
->
|
||||
Result String
|
||||
{ view :
|
||||
userModel
|
||||
-> view
|
||||
->
|
||||
{ title : String
|
||||
, body : Html userMsg
|
||||
}
|
||||
, head : List (Head.Tag PathKey)
|
||||
}
|
||||
)
|
||||
, documents : List ( String, Document.DocumentHandler metadata view )
|
||||
, manifest : Pages.Manifest.Config PathKey
|
||||
, onPageChange : PagePath PathKey -> userMsg
|
||||
, canonicalSiteUrl : String
|
||||
internals : Pages.Internal.Internal PathKey
|
||||
internals =
|
||||
{ applicationType = Pages.Internal.Browser
|
||||
, toJsPort = toJsPort
|
||||
, content = content
|
||||
, pathKey = PathKey
|
||||
}
|
||||
-> Pages.Platform.Program userModel userMsg metadata view
|
||||
application config =
|
||||
Pages.Platform.application
|
||||
{ init = config.init
|
||||
, view = config.view
|
||||
, update = config.update
|
||||
, subscriptions = config.subscriptions
|
||||
, document = Document.fromList config.documents
|
||||
, content = content
|
||||
, toJsPort = toJsPort
|
||||
, manifest = config.manifest
|
||||
, canonicalSiteUrl = config.canonicalSiteUrl
|
||||
, onPageChange = config.onPageChange
|
||||
, pathKey = PathKey
|
||||
}
|
||||
|
||||
${staticRouteStuff(staticRoutes)}
|
||||
|
||||
${generateRawContent(markdownContent, markupContent, false)}
|
||||
@ -145,6 +109,7 @@ function elmPagesCliFile(staticRoutes, markdownContent, markupContent) {
|
||||
return `port module Pages exposing ${exposingList}
|
||||
|
||||
import Color exposing (Color)
|
||||
import Pages.Internal
|
||||
import Head
|
||||
import Html exposing (Html)
|
||||
import Json.Decode
|
||||
@ -189,51 +154,13 @@ directoryWithoutIndex path =
|
||||
port toJsPort : Json.Encode.Value -> Cmd msg
|
||||
|
||||
|
||||
application :
|
||||
{ init : Maybe (PagePath PathKey) -> ( userModel, Cmd userMsg )
|
||||
, update : userMsg -> userModel -> ( userModel, Cmd userMsg )
|
||||
, subscriptions : userModel -> Sub userMsg
|
||||
, view :
|
||||
List ( PagePath PathKey, metadata )
|
||||
->
|
||||
{ path : PagePath PathKey
|
||||
, frontmatter : metadata
|
||||
}
|
||||
->
|
||||
( StaticHttp.Request
|
||||
, Json.Decode.Value
|
||||
->
|
||||
Result String
|
||||
{ view :
|
||||
userModel
|
||||
-> view
|
||||
->
|
||||
{ title : String
|
||||
, body : Html userMsg
|
||||
}
|
||||
, head : List (Head.Tag PathKey)
|
||||
}
|
||||
)
|
||||
, documents : List ( String, Document.DocumentHandler metadata view )
|
||||
, manifest : Pages.Manifest.Config PathKey
|
||||
, onPageChange : PagePath PathKey -> userMsg
|
||||
, canonicalSiteUrl : String
|
||||
internals : Pages.Internal.Internal PathKey
|
||||
internals =
|
||||
{ applicationType = Pages.Internal.Cli
|
||||
, toJsPort = toJsPort
|
||||
, content = content
|
||||
, pathKey = PathKey
|
||||
}
|
||||
-> Pages.Platform.Program userModel userMsg metadata view
|
||||
application config =
|
||||
Pages.Platform.cliApplication
|
||||
{ init = config.init
|
||||
, view = config.view
|
||||
, update = config.update
|
||||
, subscriptions = config.subscriptions
|
||||
, document = Document.fromList config.documents
|
||||
, content = content
|
||||
, toJsPort = toJsPort
|
||||
, manifest = config.manifest
|
||||
, canonicalSiteUrl = config.canonicalSiteUrl
|
||||
, onPageChange = config.onPageChange
|
||||
, pathKey = PathKey
|
||||
}
|
||||
|
||||
|
||||
${staticRouteStuff(staticRoutes)}
|
||||
|
@ -1,4 +1,7 @@
|
||||
module Pages.Platform exposing (application, Program)
|
||||
module Pages.Platform exposing
|
||||
( application, Program
|
||||
, Page
|
||||
)
|
||||
|
||||
{-| TODO
|
||||
|
||||
@ -88,3 +91,12 @@ application config =
|
||||
-}
|
||||
type alias Program model msg metadata view =
|
||||
Pages.Internal.Platform.Program model msg metadata view
|
||||
|
||||
|
||||
{-| TODO
|
||||
-}
|
||||
type alias Page metadata view pathKey =
|
||||
{ metadata : metadata
|
||||
, path : PagePath pathKey
|
||||
, view : view
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user