mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-08 23:50:36 +03:00
Merge pull request #39 from dillonkearns/query-and-fragment
Pass query params and url fragment on page changes.
This commit is contained in:
commit
1b426a9bf5
@ -106,13 +106,23 @@ type alias Model =
|
||||
}
|
||||
|
||||
|
||||
init : Maybe (PagePath Pages.PathKey) -> ( Model, Cmd Msg )
|
||||
init :
|
||||
Maybe
|
||||
{ path : PagePath Pages.PathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> ( Model, Cmd Msg )
|
||||
init maybePagePath =
|
||||
( Model False, Cmd.none )
|
||||
|
||||
|
||||
type Msg
|
||||
= OnPageChange (PagePath Pages.PathKey)
|
||||
= OnPageChange
|
||||
{ path : PagePath Pages.PathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
| ToggleMobileMenu
|
||||
|
||||
|
||||
|
@ -88,13 +88,23 @@ type alias Model =
|
||||
{}
|
||||
|
||||
|
||||
init : Maybe (PagePath Pages.PathKey) -> ( Model, Cmd Msg )
|
||||
init :
|
||||
Maybe
|
||||
{ path : PagePath Pages.PathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> ( Model, Cmd Msg )
|
||||
init maybePagePath =
|
||||
( Model, Cmd.none )
|
||||
|
||||
|
||||
type Msg
|
||||
= OnPageChange (PagePath Pages.PathKey)
|
||||
= OnPageChange
|
||||
{ path : PagePath Pages.PathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
|
@ -247,7 +247,14 @@ init :
|
||||
}
|
||||
)
|
||||
-> Content
|
||||
-> (Maybe (PagePath pathKey) -> ( userModel, Cmd userMsg ))
|
||||
->
|
||||
(Maybe
|
||||
{ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> ( userModel, Cmd userMsg )
|
||||
)
|
||||
-> Flags
|
||||
-> Url
|
||||
-> Browser.Navigation.Key
|
||||
@ -283,7 +290,16 @@ init pathKey canonicalSiteUrl document toJsPort viewFn content initUserModel fla
|
||||
Client
|
||||
|
||||
( userModel, userCmd ) =
|
||||
initUserModel maybePagePath
|
||||
initUserModel
|
||||
(maybePagePath
|
||||
|> Maybe.map
|
||||
(\pagePath ->
|
||||
{ path = pagePath
|
||||
, query = url.query
|
||||
, fragment = url.fragment
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
cmd =
|
||||
case ( maybePagePath, maybeMetadata ) of
|
||||
@ -387,7 +403,13 @@ update :
|
||||
}
|
||||
)
|
||||
-> pathKey
|
||||
-> (PagePath pathKey -> userMsg)
|
||||
->
|
||||
({ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> userMsg
|
||||
)
|
||||
-> (Json.Encode.Value -> Cmd Never)
|
||||
-> Pages.Document.Document metadata view
|
||||
-> (userMsg -> userModel -> ( userModel, Cmd userMsg ))
|
||||
@ -488,7 +510,12 @@ update canonicalSiteUrl viewFunction pathKey onPageChangeMsg toJsPort document u
|
||||
let
|
||||
( userModel, userCmd ) =
|
||||
userUpdate
|
||||
(onPageChangeMsg (url |> urlToPagePath pathKey))
|
||||
(onPageChangeMsg
|
||||
{ path = url |> urlToPagePath pathKey
|
||||
, query = url.query
|
||||
, fragment = url.fragment
|
||||
}
|
||||
)
|
||||
model.userModel
|
||||
in
|
||||
( { model
|
||||
@ -515,7 +542,13 @@ type alias Parser metadata view =
|
||||
|
||||
|
||||
application :
|
||||
{ init : Maybe (PagePath pathKey) -> ( userModel, Cmd userMsg )
|
||||
{ init :
|
||||
Maybe
|
||||
{ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> ( userModel, Cmd userMsg )
|
||||
, update : userMsg -> userModel -> ( userModel, Cmd userMsg )
|
||||
, subscriptions : userModel -> Sub userMsg
|
||||
, view :
|
||||
@ -548,7 +581,12 @@ application :
|
||||
)
|
||||
, canonicalSiteUrl : String
|
||||
, pathKey : pathKey
|
||||
, onPageChange : PagePath pathKey -> userMsg
|
||||
, onPageChange :
|
||||
{ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> userMsg
|
||||
}
|
||||
-- -> Program userModel userMsg metadata view
|
||||
-> Platform.Program Flags (Model userModel userMsg metadata view) (Msg userMsg metadata view)
|
||||
@ -608,7 +646,13 @@ application config =
|
||||
|
||||
|
||||
cliApplication :
|
||||
{ init : Maybe (PagePath pathKey) -> ( userModel, Cmd userMsg )
|
||||
{ init :
|
||||
Maybe
|
||||
{ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> ( userModel, Cmd userMsg )
|
||||
, update : userMsg -> userModel -> ( userModel, Cmd userMsg )
|
||||
, subscriptions : userModel -> Sub userMsg
|
||||
, view :
|
||||
@ -641,7 +685,12 @@ cliApplication :
|
||||
)
|
||||
, canonicalSiteUrl : String
|
||||
, pathKey : pathKey
|
||||
, onPageChange : PagePath pathKey -> userMsg
|
||||
, onPageChange :
|
||||
{ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> userMsg
|
||||
}
|
||||
-> Program userModel userMsg metadata view
|
||||
cliApplication =
|
||||
|
@ -151,7 +151,13 @@ type Msg
|
||||
|
||||
|
||||
type alias Config pathKey userMsg userModel metadata view =
|
||||
{ init : Maybe (PagePath pathKey) -> ( userModel, Cmd userMsg )
|
||||
{ init :
|
||||
Maybe
|
||||
{ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> ( userModel, Cmd userMsg )
|
||||
, update : userMsg -> userModel -> ( userModel, Cmd userMsg )
|
||||
, subscriptions : userModel -> Sub userMsg
|
||||
, view :
|
||||
@ -184,7 +190,12 @@ type alias Config pathKey userMsg userModel metadata view =
|
||||
)
|
||||
, canonicalSiteUrl : String
|
||||
, pathKey : pathKey
|
||||
, onPageChange : PagePath pathKey -> userMsg
|
||||
, onPageChange :
|
||||
{ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> userMsg
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,13 @@ which case there is no pre-rendering).
|
||||
|
||||
-}
|
||||
application :
|
||||
{ init : Maybe (PagePath pathKey) -> ( userModel, Cmd userMsg )
|
||||
{ init :
|
||||
Maybe
|
||||
{ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> ( userModel, Cmd userMsg )
|
||||
, update : userMsg -> userModel -> ( userModel, Cmd userMsg )
|
||||
, subscriptions : userModel -> Sub userMsg
|
||||
, view :
|
||||
@ -90,7 +96,12 @@ application :
|
||||
, content : String
|
||||
}
|
||||
)
|
||||
, onPageChange : PagePath pathKey -> userMsg
|
||||
, onPageChange :
|
||||
{ path : PagePath pathKey
|
||||
, query : Maybe String
|
||||
, fragment : Maybe String
|
||||
}
|
||||
-> userMsg
|
||||
, canonicalSiteUrl : String
|
||||
, internals : Pages.Internal.Internal pathKey
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user