mirror of
https://github.com/dillonkearns/elm-pages.git
synced 2024-10-26 10:27:36 +03:00
Rename routes to pages. Routes are the category of page, pages are the specific things to pre-render for a given route, so this terminology is more consistent and clear.
This commit is contained in:
parent
6583738ab2
commit
010cfb9c2a
@ -41,13 +41,13 @@ page =
|
||||
Page.prerender
|
||||
{ data = data
|
||||
, head = head
|
||||
, routes = routes
|
||||
, pages = pages
|
||||
}
|
||||
|> Page.buildNoState { view = view }
|
||||
|
||||
|
||||
routes : DataSource.DataSource (List RouteParams)
|
||||
routes =
|
||||
pages : DataSource.DataSource (List RouteParams)
|
||||
pages =
|
||||
Article.blogPostsGlob
|
||||
|> DataSource.map
|
||||
(List.map
|
||||
|
@ -45,7 +45,7 @@ page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
{ head = head
|
||||
, routes = routes
|
||||
, pages = pages
|
||||
, data = data
|
||||
}
|
||||
|> Page.buildNoState
|
||||
@ -53,8 +53,8 @@ page =
|
||||
}
|
||||
|
||||
|
||||
routes : DataSource (List RouteParams)
|
||||
routes =
|
||||
pages : DataSource (List RouteParams)
|
||||
pages =
|
||||
DocsSection.all
|
||||
|> DataSource.map
|
||||
(List.map
|
||||
|
@ -145,13 +145,13 @@ page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
{ head = head
|
||||
, routes = routes
|
||||
, pages = pages
|
||||
, data = data
|
||||
}
|
||||
|> Page.buildNoState { view = view }
|
||||
|
||||
routes : DataSource (List RouteParams)
|
||||
routes =
|
||||
pages : DataSource (List RouteParams)
|
||||
pages =
|
||||
DataSource.succeed [ { name = "elm-pages" } ]
|
||||
|
||||
data : RouteParams -> DataSource Data
|
||||
|
@ -32,7 +32,7 @@ page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerenderWithFallback
|
||||
{ head = head
|
||||
, routes = routes
|
||||
, pages = pages
|
||||
, data = data
|
||||
, handleFallback =
|
||||
\{ pokedexNumber } ->
|
||||
@ -47,8 +47,8 @@ page =
|
||||
|> Page.buildNoState { view = view }
|
||||
|
||||
|
||||
routes : DataSource (List RouteParams)
|
||||
routes =
|
||||
pages : DataSource (List RouteParams)
|
||||
pages =
|
||||
DataSource.succeed []
|
||||
|
||||
|
||||
|
@ -27,14 +27,14 @@ page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
{ head = head
|
||||
, routes = routes
|
||||
, pages = pages
|
||||
, data = data
|
||||
}
|
||||
|> Page.buildNoState { view = view }
|
||||
|
||||
|
||||
routes : DataSource.DataSource (List RouteParams)
|
||||
routes =
|
||||
pages : DataSource.DataSource (List RouteParams)
|
||||
pages =
|
||||
DataSource.succeed
|
||||
[ { name = Just "larry"
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
{ head = head
|
||||
, routes = routes
|
||||
, pages = pages
|
||||
, data = data
|
||||
|
||||
--, routeFound = \_ -> DataSource.succeed True
|
||||
@ -33,8 +33,8 @@ page =
|
||||
|> Page.buildNoState { view = view }
|
||||
|
||||
|
||||
routes : DataSource.DataSource (List RouteParams)
|
||||
routes =
|
||||
pages : DataSource.DataSource (List RouteParams)
|
||||
pages =
|
||||
DataSource.succeed
|
||||
[ { splat = ( "2021", [ "04", "28" ] )
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
{ head = head
|
||||
, routes = DataSource.succeed []
|
||||
, pages = DataSource.succeed []
|
||||
, data = data
|
||||
|
||||
--, routeFound = \_ -> DataSource.succeed True
|
||||
|
@ -38,7 +38,7 @@ page : Page.PageWithState RouteParams Data Model Msg
|
||||
page =
|
||||
Page.prerender
|
||||
{ head = head
|
||||
, routes =
|
||||
, pages =
|
||||
slideCount
|
||||
|> DataSource.map
|
||||
(\count ->
|
||||
|
@ -26,14 +26,14 @@ page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
{ head = head
|
||||
, routes = routes
|
||||
, pages = pages
|
||||
, data = data
|
||||
}
|
||||
|> Page.buildNoState { view = view }
|
||||
|
||||
|
||||
routes : DataSource.DataSource (List RouteParams)
|
||||
routes =
|
||||
pages : DataSource.DataSource (List RouteParams)
|
||||
pages =
|
||||
DataSource.succeed
|
||||
[ { name = Just "larry"
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ page : Page.PageWithState RouteParams Data Model Msg
|
||||
page =
|
||||
Page.prerender
|
||||
{ head = head
|
||||
, routes =
|
||||
, pages =
|
||||
slideCount
|
||||
|> DataSource.map
|
||||
(\count ->
|
||||
|
@ -50,18 +50,18 @@ A `single` page is just a Route that has no Dynamic Route Segments. For example,
|
||||
|
||||
When you run `elm-pages add About`, it will use `Page.single { ... }` because it has empty `RouteParams`. When you run `elm-pages add Blog.Slug_`, will will use `Page.prerender` because it has a Dynamic Route Segment.
|
||||
|
||||
So `Page.single` is just a simplified version of `Page.prerender`. If there are no Dynamic Route Segments, then you don't need to define which routes to render so `Page.single` doesn't need a `routes` field.
|
||||
So `Page.single` is just a simplified version of `Page.prerender`. If there are no Dynamic Route Segments, then you don't need to define which pages to render so `Page.single` doesn't need a `pages` field.
|
||||
|
||||
When there are Dynamic Route Segments, you need to tell `elm-pages` which pages to render. For example:
|
||||
|
||||
page =
|
||||
Page.prerender
|
||||
{ data = data
|
||||
, routes = routes
|
||||
, pages = pages
|
||||
, head = head
|
||||
}
|
||||
|
||||
routes =
|
||||
pages =
|
||||
DataSource.succeed
|
||||
[ { slug_ = "blog-post1" }
|
||||
, { slug_ = "blog-post2" }
|
||||
@ -271,19 +271,19 @@ single { data, head } =
|
||||
{-| -}
|
||||
prerender :
|
||||
{ data : routeParams -> DataSource data
|
||||
, routes : DataSource (List routeParams)
|
||||
, pages : DataSource (List routeParams)
|
||||
, head : StaticPayload data routeParams -> List Head.Tag
|
||||
}
|
||||
-> Builder routeParams data
|
||||
prerender { data, head, routes } =
|
||||
prerender { data, head, pages } =
|
||||
WithData
|
||||
{ data = data
|
||||
, staticRoutes = routes
|
||||
, staticRoutes = pages
|
||||
, head = head
|
||||
, serverless = False
|
||||
, handleRoute =
|
||||
\moduleContext toRecord routeParams ->
|
||||
routes
|
||||
pages
|
||||
|> DataSource.map
|
||||
(\allRoutes ->
|
||||
if allRoutes |> List.member routeParams then
|
||||
@ -309,15 +309,15 @@ prerender { data, head, routes } =
|
||||
--{-| -}
|
||||
--prerenderWithFallback :
|
||||
-- { data : routeParams -> DataSource data
|
||||
-- , routes : DataSource (List routeParams)
|
||||
-- , pages : DataSource (List routeParams)
|
||||
-- , handleFallback : routeParams -> DataSource Bool
|
||||
-- , head : StaticPayload data routeParams -> List Head.Tag
|
||||
-- }
|
||||
-- -> Builder routeParams data
|
||||
--prerenderWithFallback { data, head, routes, handleFallback } =
|
||||
--prerenderWithFallback { data, head, pages, handleFallback } =
|
||||
-- WithData
|
||||
-- { data = data
|
||||
-- , staticRoutes = routes
|
||||
-- , staticRoutes = pages
|
||||
-- , head = head
|
||||
-- , serverless = False
|
||||
-- , handleRoute =
|
||||
@ -335,7 +335,7 @@ prerender { data, head, routes } =
|
||||
-- -- between on-demand builders and the dev server
|
||||
-- -- we only need to match the pre-rendered routes in the dev server,
|
||||
-- -- not in on-demand builders
|
||||
-- routes
|
||||
-- pages
|
||||
-- |> DataSource.map
|
||||
-- (\allRoutes ->
|
||||
-- if allRoutes |> List.member routeParams then
|
||||
|
@ -73,7 +73,7 @@ page =
|
||||
withParams
|
||||
? `Page.prerender
|
||||
{ head = head
|
||||
, routes = routes
|
||||
, pages = pages
|
||||
, data = data
|
||||
}`
|
||||
: `Page.single
|
||||
@ -135,8 +135,8 @@ subscriptions maybePageUrl routeParams path model =
|
||||
|
||||
${
|
||||
withParams
|
||||
? `routes : DataSource (List RouteParams)
|
||||
routes =
|
||||
? `pages : DataSource (List RouteParams)
|
||||
pages =
|
||||
DataSource.succeed []
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user