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:
Dillon Kearns 2021-12-10 16:03:07 -08:00
parent 6583738ab2
commit 010cfb9c2a
12 changed files with 38 additions and 38 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 []

View File

@ -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"
}

View File

@ -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" ] )
}

View File

@ -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

View File

@ -38,7 +38,7 @@ page : Page.PageWithState RouteParams Data Model Msg
page =
Page.prerender
{ head = head
, routes =
, pages =
slideCount
|> DataSource.map
(\count ->

View File

@ -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"
}

View File

@ -36,7 +36,7 @@ page : Page.PageWithState RouteParams Data Model Msg
page =
Page.prerender
{ head = head
, routes =
, pages =
slideCount
|> DataSource.map
(\count ->

View File

@ -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

View File

@ -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 []