diff --git a/examples/docs/app/Effect.elm b/examples/docs/app/Effect.elm index 714fc76f..6383d1cb 100644 --- a/examples/docs/app/Effect.elm +++ b/examples/docs/app/Effect.elm @@ -3,6 +3,7 @@ module Effect exposing (Effect(..), batch, fromCmd, map, none, perform) import Browser.Navigation import Bytes exposing (Bytes) import Bytes.Decode +import FormDecoder import Http import Json.Decode as Decode import Pages.Fetcher @@ -15,14 +16,11 @@ type Effect msg | Batch (List (Effect msg)) | GetStargazers (Result Http.Error Int -> msg) | FetchRouteData - { body : Maybe { contentType : String, body : String } - , path : Maybe String + { data : Maybe FormDecoder.FormData , toMsg : Result Http.Error Url -> msg } | Submit - { values : List ( String, String ) - , path : Maybe (List String) - , method : Maybe String + { values : FormDecoder.FormData , toMsg : Result Http.Error Url -> msg } | SubmitFetcher (Pages.Fetcher.Fetcher msg) @@ -66,16 +64,13 @@ map fn effect = FetchRouteData fetchInfo -> FetchRouteData - { body = fetchInfo.body - , path = fetchInfo.path + { data = fetchInfo.data , toMsg = fetchInfo.toMsg >> fn } Submit fetchInfo -> Submit { values = fetchInfo.values - , path = fetchInfo.path - , method = fetchInfo.method , toMsg = fetchInfo.toMsg >> fn } @@ -87,16 +82,12 @@ map fn effect = perform : { fetchRouteData : - { body : Maybe { contentType : String, body : String } - , path : Maybe String + { data : Maybe FormDecoder.FormData , toMsg : Result Http.Error Url -> pageMsg } -> Cmd msg , submit : - { values : List ( String, String ) - , encType : Maybe String - , method : Maybe String - , path : Maybe String + { values : FormDecoder.FormData , toMsg : Result Http.Error Url -> pageMsg } -> Cmd msg @@ -128,19 +119,10 @@ perform ({ fromPageMsg, key } as helpers) effect = FetchRouteData fetchInfo -> helpers.fetchRouteData - { body = fetchInfo.body - , path = fetchInfo.path - , toMsg = fetchInfo.toMsg - } + fetchInfo Submit record -> - helpers.submit - { values = record.values - , path = Nothing --fetchInfo.path - , method = record.method - , encType = Nothing -- TODO - , toMsg = record.toMsg - } + helpers.submit record SubmitFetcher record -> helpers.runFetcher record diff --git a/examples/docs/app/Route/Blog/Slug_.elm b/examples/docs/app/Route/Blog/Slug_.elm index 6cd56653..3b9b698e 100644 --- a/examples/docs/app/Route/Blog/Slug_.elm +++ b/examples/docs/app/Route/Blog/Slug_.elm @@ -14,6 +14,7 @@ import Json.Decode.Extra import Markdown.Block import Markdown.Renderer import MarkdownCodec +import Pages.Msg import Pages.PageUrl exposing (PageUrl) import Pages.Url import Path @@ -64,7 +65,7 @@ view : Maybe PageUrl -> Shared.Model -> StaticPayload Data ActionData RouteParams - -> View Msg + -> View (Pages.Msg.Msg Msg) view maybeUrl sharedModel static = { title = static.data.metadata.title , body = diff --git a/examples/docs/app/Route/Docs/Section__.elm b/examples/docs/app/Route/Docs/Section__.elm index 8b4e3673..5de689a8 100644 --- a/examples/docs/app/Route/Docs/Section__.elm +++ b/examples/docs/app/Route/Docs/Section__.elm @@ -17,6 +17,7 @@ import Markdown.Parser import Markdown.Renderer import MarkdownCodec import NextPrevious +import Pages.Msg import Pages.PageUrl exposing (PageUrl) import Pages.Url import RouteBuilder exposing (StatelessRoute, StaticPayload) @@ -198,7 +199,7 @@ view : Maybe PageUrl -> Shared.Model -> StaticPayload Data ActionData RouteParams - -> View Msg + -> View (Pages.Msg.Msg Msg) view maybeUrl sharedModel static = { title = static.data.titles.title ++ " - elm-pages docs" , body = diff --git a/examples/docs/app/Route/Index.elm b/examples/docs/app/Route/Index.elm index 74c52466..fb1a6e54 100644 --- a/examples/docs/app/Route/Index.elm +++ b/examples/docs/app/Route/Index.elm @@ -4,9 +4,10 @@ import Css import DataSource exposing (DataSource) import Head import Head.Seo as Seo -import Html.Styled exposing (..) +import Html.Styled as Html exposing (..) import Html.Styled.Attributes as Attr exposing (css) import Link +import Pages.Msg import Pages.PageUrl exposing (PageUrl) import Pages.Url import Path @@ -75,11 +76,11 @@ view : Maybe PageUrl -> Shared.Model -> StaticPayload Data ActionData RouteParams - -> View Msg + -> View (Pages.Msg.Msg Msg) view maybeUrl sharedModel static = { title = "elm-pages - a statically typed site generator" , body = - [ landingView + [ landingView |> Html.map Pages.Msg.UserMsg ] } diff --git a/examples/docs/app/Route/Showcase.elm b/examples/docs/app/Route/Showcase.elm index 6f673380..bb3f69a6 100644 --- a/examples/docs/app/Route/Showcase.elm +++ b/examples/docs/app/Route/Showcase.elm @@ -6,6 +6,7 @@ import Head import Head.Seo as Seo import Html.Styled exposing (..) import Html.Styled.Attributes as Attr exposing (css, href) +import Pages.Msg import Pages.PageUrl exposing (PageUrl) import Pages.Url import Path @@ -55,7 +56,7 @@ view : Maybe PageUrl -> Shared.Model -> StaticPayload Data ActionData {} - -> View Msg + -> View (Pages.Msg.Msg Msg) view maybeUrl sharedModel static = { title = "elm-pages blog" , body =