mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-27 21:29:55 +03:00
Update pokedex example.
This commit is contained in:
parent
b2f514d0b0
commit
dacba7358e
@ -16,7 +16,7 @@ import View exposing (View)
|
|||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
()
|
{}
|
||||||
|
|
||||||
|
|
||||||
type alias Msg =
|
type alias Msg =
|
||||||
|
@ -17,7 +17,7 @@ import View exposing (View)
|
|||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
()
|
{}
|
||||||
|
|
||||||
|
|
||||||
type alias Msg =
|
type alias Msg =
|
||||||
|
@ -14,12 +14,11 @@ type alias Data =
|
|||||||
|
|
||||||
config : SiteConfig Data
|
config : SiteConfig Data
|
||||||
config =
|
config =
|
||||||
\routes ->
|
{ data = data
|
||||||
{ data = data
|
, canonicalUrl = "https://elm-pages.com"
|
||||||
, canonicalUrl = "https://elm-pages.com"
|
, manifest = manifest
|
||||||
, manifest = manifest
|
, head = head
|
||||||
, head = head
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
data : DataSource.DataSource Data
|
data : DataSource.DataSource Data
|
||||||
|
@ -5,7 +5,7 @@ module Page exposing
|
|||||||
, prerender, single
|
, prerender, single
|
||||||
, Builder(..)
|
, Builder(..)
|
||||||
, PageWithState
|
, PageWithState
|
||||||
--, serverless, prerenderWithFallback
|
, serverless, prerenderWithFallback
|
||||||
)
|
)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
@ -77,8 +77,7 @@ When there are Dynamic Route Segments, you need to tell `elm-pages` which pages
|
|||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
--import DataSource.ServerRequest as ServerRequest exposing (ServerRequest)
|
import DataSource.ServerRequest as ServerRequest exposing (ServerRequest)
|
||||||
|
|
||||||
import Browser.Navigation
|
import Browser.Navigation
|
||||||
import DataSource exposing (DataSource)
|
import DataSource exposing (DataSource)
|
||||||
import Head
|
import Head
|
||||||
@ -306,88 +305,88 @@ prerender { data, head, pages } =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--{-| -}
|
{-| -}
|
||||||
--prerenderWithFallback :
|
prerenderWithFallback :
|
||||||
-- { data : routeParams -> DataSource data
|
{ data : routeParams -> DataSource data
|
||||||
-- , pages : DataSource (List routeParams)
|
, pages : DataSource (List routeParams)
|
||||||
-- , handleFallback : routeParams -> DataSource Bool
|
, handleFallback : routeParams -> DataSource Bool
|
||||||
-- , head : StaticPayload data routeParams -> List Head.Tag
|
, head : StaticPayload data routeParams -> List Head.Tag
|
||||||
-- }
|
}
|
||||||
-- -> Builder routeParams data
|
-> Builder routeParams data
|
||||||
--prerenderWithFallback { data, head, pages, handleFallback } =
|
prerenderWithFallback { data, head, pages, handleFallback } =
|
||||||
-- WithData
|
WithData
|
||||||
-- { data = data
|
{ data = data
|
||||||
-- , staticRoutes = pages
|
, staticRoutes = pages
|
||||||
-- , head = head
|
, head = head
|
||||||
-- , serverless = False
|
, serverless = False
|
||||||
-- , handleRoute =
|
, handleRoute =
|
||||||
-- \moduleContext toRecord routeParams ->
|
\moduleContext toRecord routeParams ->
|
||||||
-- handleFallback routeParams
|
handleFallback routeParams
|
||||||
-- |> DataSource.andThen
|
|> DataSource.andThen
|
||||||
-- (\handleFallbackResult ->
|
(\handleFallbackResult ->
|
||||||
-- if handleFallbackResult then
|
if handleFallbackResult then
|
||||||
-- DataSource.succeed Nothing
|
DataSource.succeed Nothing
|
||||||
--
|
|
||||||
-- else
|
else
|
||||||
-- -- we want to lazily evaluate this in our on-demand builders
|
-- we want to lazily evaluate this in our on-demand builders
|
||||||
-- -- so we try handle fallback first and short-circuit in those cases
|
-- so we try handle fallback first and short-circuit in those cases
|
||||||
-- -- TODO - we could make an optimization to handle this differently
|
-- TODO - we could make an optimization to handle this differently
|
||||||
-- -- between on-demand builders and the dev server
|
-- between on-demand builders and the dev server
|
||||||
-- -- we only need to match the pre-rendered routes in the dev server,
|
-- we only need to match the pre-rendered routes in the dev server,
|
||||||
-- -- not in on-demand builders
|
-- not in on-demand builders
|
||||||
-- pages
|
pages
|
||||||
-- |> DataSource.map
|
|> DataSource.map
|
||||||
-- (\allRoutes ->
|
(\allRoutes ->
|
||||||
-- if allRoutes |> List.member routeParams then
|
if allRoutes |> List.member routeParams then
|
||||||
-- Nothing
|
Nothing
|
||||||
--
|
|
||||||
-- else
|
else
|
||||||
-- Just <|
|
Just <|
|
||||||
-- NotFoundReason.NotPrerenderedOrHandledByFallback
|
Pages.Internal.NotFoundReason.NotPrerenderedOrHandledByFallback
|
||||||
-- { moduleName = moduleContext.moduleName
|
{ moduleName = moduleContext.moduleName
|
||||||
-- , routePattern = moduleContext.routePattern
|
, routePattern = moduleContext.routePattern
|
||||||
-- , matchedRouteParams = toRecord routeParams
|
, matchedRouteParams = toRecord routeParams
|
||||||
-- }
|
}
|
||||||
-- (allRoutes
|
(allRoutes
|
||||||
-- |> List.map toRecord
|
|> List.map toRecord
|
||||||
-- )
|
)
|
||||||
-- )
|
)
|
||||||
-- )
|
)
|
||||||
-- , kind = "prerender-with-fallback"
|
, kind = "prerender-with-fallback"
|
||||||
-- }
|
}
|
||||||
--
|
|
||||||
--
|
|
||||||
--{-| -}
|
{-| -}
|
||||||
--serverless :
|
serverless :
|
||||||
-- { data : (ServerRequest decodedRequest -> DataSource decodedRequest) -> routeParams -> DataSource data
|
{ data : (ServerRequest decodedRequest -> DataSource decodedRequest) -> routeParams -> DataSource data
|
||||||
-- , routeFound : routeParams -> DataSource Bool
|
, routeFound : routeParams -> DataSource Bool
|
||||||
-- , head : StaticPayload data routeParams -> List Head.Tag
|
, head : StaticPayload data routeParams -> List Head.Tag
|
||||||
-- }
|
}
|
||||||
-- -> Builder routeParams data
|
-> Builder routeParams data
|
||||||
--serverless { data, head, routeFound } =
|
serverless { data, head, routeFound } =
|
||||||
-- WithData
|
WithData
|
||||||
-- { data = data ServerRequest.toStaticHttp
|
{ data = data ServerRequest.toStaticHttp
|
||||||
-- , staticRoutes = DataSource.succeed []
|
, staticRoutes = DataSource.succeed []
|
||||||
-- , head = head
|
, head = head
|
||||||
-- , serverless = True
|
, serverless = True
|
||||||
-- , handleRoute =
|
, handleRoute =
|
||||||
-- \moduleContext toRecord routeParams ->
|
\moduleContext toRecord routeParams ->
|
||||||
-- routeFound routeParams
|
routeFound routeParams
|
||||||
-- |> DataSource.map
|
|> DataSource.map
|
||||||
-- (\found ->
|
(\found ->
|
||||||
-- if found then
|
if found then
|
||||||
-- Nothing
|
Nothing
|
||||||
--
|
|
||||||
-- else
|
else
|
||||||
-- Just
|
Just
|
||||||
-- (NotFoundReason.UnhandledServerRoute
|
(Pages.Internal.NotFoundReason.UnhandledServerRoute
|
||||||
-- { moduleName = moduleContext.moduleName
|
{ moduleName = moduleContext.moduleName
|
||||||
-- , routePattern = moduleContext.routePattern
|
, routePattern = moduleContext.routePattern
|
||||||
-- , matchedRouteParams = toRecord routeParams
|
, matchedRouteParams = toRecord routeParams
|
||||||
-- }
|
}
|
||||||
-- )
|
)
|
||||||
-- )
|
)
|
||||||
-- , kind = "serverless"
|
, kind = "serverless"
|
||||||
-- }
|
}
|
||||||
--
|
|
||||||
--
|
|
||||||
|
Loading…
Reference in New Issue
Block a user