mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-27 11:05:46 +03:00
Change decoding format for single page routes.
This commit is contained in:
parent
9a089b3957
commit
3c14865d2b
@ -54,7 +54,11 @@ function runElmApp(compiledElmPath, pagePath, request, addDataSourceWatcher) {
|
||||
secrets: process.env,
|
||||
mode,
|
||||
staticHttpCache: global.staticHttpCache,
|
||||
request: modifiedRequest,
|
||||
request: {
|
||||
payload: modifiedRequest,
|
||||
kind: "single-page",
|
||||
jsonOnly: isJson,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -38,20 +38,7 @@ decoder :
|
||||
-> Decode.Decoder (RenderRequest route)
|
||||
decoder config =
|
||||
optionalField "request"
|
||||
(Decode.field "path"
|
||||
(Decode.string
|
||||
|> Decode.map
|
||||
(\path ->
|
||||
let
|
||||
route =
|
||||
pathToUrl path |> config.urlToRoute
|
||||
in
|
||||
{ frontmatter = route
|
||||
, path = config.routeToPath route |> PagePath.build
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
(requestPayloadDecoder config)
|
||||
|> Decode.map
|
||||
(\maybeRequest ->
|
||||
case maybeRequest of
|
||||
@ -63,6 +50,34 @@ decoder config =
|
||||
)
|
||||
|
||||
|
||||
|
||||
{-
|
||||
payload: modifiedRequest,
|
||||
kind: "single-page",
|
||||
jsonOnly: isJson,
|
||||
-}
|
||||
|
||||
|
||||
requestPayloadDecoder :
|
||||
ProgramConfig userMsg userModel route siteStaticData pageStaticData sharedStaticData
|
||||
-> Decode.Decoder (RequestPayload route)
|
||||
requestPayloadDecoder config =
|
||||
(Decode.string
|
||||
|> Decode.map
|
||||
(\path ->
|
||||
let
|
||||
route =
|
||||
pathToUrl path |> config.urlToRoute
|
||||
in
|
||||
{ frontmatter = route
|
||||
, path = config.routeToPath route |> PagePath.build
|
||||
}
|
||||
)
|
||||
)
|
||||
|> Decode.field "path"
|
||||
|> Decode.field "payload"
|
||||
|
||||
|
||||
pathToUrl : String -> Url
|
||||
pathToUrl path =
|
||||
{ protocol = Url.Https
|
||||
|
Loading…
Reference in New Issue
Block a user