mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-28 22:37:08 +03:00
Rename prerender -> preRender.
This commit is contained in:
parent
afb81f7224
commit
4fedf9ee19
@ -38,7 +38,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ data = data
|
||||
, head = head
|
||||
, routes = routes
|
||||
|
@ -45,7 +45,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ data = data
|
||||
, head = head
|
||||
, routes = routes
|
||||
|
@ -38,7 +38,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ data = data
|
||||
, head = head
|
||||
, pages = pages
|
||||
|
@ -43,7 +43,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ head = head
|
||||
, pages = pages
|
||||
, data = data
|
||||
|
@ -143,7 +143,7 @@ type alias RouteParams = { name : String }
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ head = head
|
||||
, pages = pages
|
||||
, data = data
|
||||
|
@ -39,7 +39,7 @@ serverRequestInfo =
|
||||
|> ApiRoute.literal "api"
|
||||
|> ApiRoute.slash
|
||||
|> ApiRoute.literal "request"
|
||||
|> ApiRoute.serverless
|
||||
|> ApiRoute.serverRender
|
||||
|
||||
|
||||
redirectRoute : ApiRoute ApiRoute.Response
|
||||
@ -52,7 +52,7 @@ redirectRoute =
|
||||
|> ApiRoute.literal "api"
|
||||
|> ApiRoute.slash
|
||||
|> ApiRoute.literal "redirect"
|
||||
|> ApiRoute.serverless
|
||||
|> ApiRoute.serverRender
|
||||
|
||||
|
||||
serverRequestDataSource isAvailable =
|
||||
@ -92,7 +92,7 @@ noArgs =
|
||||
|> ApiRoute.literal "api"
|
||||
|> ApiRoute.slash
|
||||
|> ApiRoute.literal "stars"
|
||||
|> ApiRoute.serverless
|
||||
|> ApiRoute.serverRender
|
||||
|
||||
|
||||
nonHybridRoute =
|
||||
@ -133,7 +133,7 @@ logout =
|
||||
|> ApiRoute.literal "api"
|
||||
|> ApiRoute.slash
|
||||
|> ApiRoute.literal "logout"
|
||||
|> ApiRoute.serverless
|
||||
|> ApiRoute.serverRender
|
||||
|
||||
|
||||
repoStars : ApiRoute ApiRoute.Response
|
||||
@ -158,7 +158,7 @@ repoStars =
|
||||
|> ApiRoute.slash
|
||||
|> ApiRoute.capture
|
||||
--|> ApiRoute.literal ".json"
|
||||
|> ApiRoute.serverless
|
||||
|> ApiRoute.serverRender
|
||||
|
||||
|
||||
repoStars2 : ApiRoute ApiRoute.Response
|
||||
@ -182,7 +182,7 @@ repoStars2 =
|
||||
|> ApiRoute.literal "repo"
|
||||
|> ApiRoute.slash
|
||||
|> ApiRoute.capture
|
||||
|> ApiRoute.prerenderWithFallback
|
||||
|> ApiRoute.preRenderWithFallback
|
||||
(\route ->
|
||||
DataSource.succeed
|
||||
[ route "elm-graphql"
|
||||
|
@ -31,7 +31,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.serverless
|
||||
Page.serverRender
|
||||
{ head = head
|
||||
, data = data
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.serverless
|
||||
Page.serverRender
|
||||
{ head = head
|
||||
, data = data
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerenderWithFallback
|
||||
Page.preRenderWithFallback
|
||||
{ head = head
|
||||
, pages = pages
|
||||
, data = data
|
||||
|
@ -31,7 +31,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.serverless
|
||||
Page.serverRender
|
||||
{ head = head
|
||||
, data = data
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ head = head
|
||||
, pages = pages
|
||||
, data = data
|
||||
|
@ -23,7 +23,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ head = head
|
||||
, pages = pages
|
||||
, data = data
|
||||
|
@ -23,7 +23,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ head = head
|
||||
, pages = DataSource.succeed []
|
||||
, data = data
|
||||
|
@ -36,7 +36,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page.PageWithState RouteParams Data Model Msg
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ head = head
|
||||
, pages =
|
||||
slideCount
|
||||
|
@ -24,7 +24,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page RouteParams Data
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ head = head
|
||||
, pages = pages
|
||||
, data = data
|
||||
|
@ -34,7 +34,7 @@ type alias RouteParams =
|
||||
|
||||
page : Page.PageWithState RouteParams Data Model Msg
|
||||
page =
|
||||
Page.prerender
|
||||
Page.preRender
|
||||
{ head = head
|
||||
, pages =
|
||||
slideCount
|
||||
|
@ -2,10 +2,10 @@ module Page exposing
|
||||
( Page, buildNoState
|
||||
, StaticPayload
|
||||
, buildWithLocalState, buildWithSharedState
|
||||
, prerender, single
|
||||
, preRender, single
|
||||
, Builder(..)
|
||||
, PageWithState
|
||||
, prerenderWithFallback, serverless
|
||||
, preRenderWithFallback, serverRender
|
||||
)
|
||||
|
||||
{-|
|
||||
@ -48,14 +48,14 @@ We have the following data during pre-render:
|
||||
|
||||
A `single` page is just a Route that has no Dynamic Route Segments. For example, `Page.About` will have `type alias RouteParams = {}`, whereas `Page.Blog.Slug_` has a Dynamic Segment slug, and `type alias RouteParams = { slug : String }`.
|
||||
|
||||
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.
|
||||
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 pages to render so `Page.single` doesn't need a `pages` 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
|
||||
Page.preRender
|
||||
{ data = data
|
||||
, pages = pages
|
||||
, head = head
|
||||
@ -67,7 +67,7 @@ When there are Dynamic Route Segments, you need to tell `elm-pages` which pages
|
||||
, { slug = "blog-post2" }
|
||||
]
|
||||
|
||||
@docs prerender, single
|
||||
@docs preRender, single
|
||||
|
||||
|
||||
## Internals
|
||||
@ -271,13 +271,13 @@ single { data, head } =
|
||||
|
||||
|
||||
{-| -}
|
||||
prerender :
|
||||
preRender :
|
||||
{ data : routeParams -> DataSource data
|
||||
, pages : DataSource (List routeParams)
|
||||
, head : StaticPayload data routeParams -> List Head.Tag
|
||||
}
|
||||
-> Builder routeParams data
|
||||
prerender { data, head, pages } =
|
||||
preRender { data, head, pages } =
|
||||
WithData
|
||||
{ data = \_ -> data >> DataSource.map PageServerResponse.RenderPage
|
||||
, staticRoutes = pages
|
||||
@ -308,13 +308,13 @@ prerender { data, head, pages } =
|
||||
|
||||
|
||||
{-| -}
|
||||
prerenderWithFallback :
|
||||
preRenderWithFallback :
|
||||
{ data : routeParams -> DataSource (PageServerResponse data)
|
||||
, pages : DataSource (List routeParams)
|
||||
, head : StaticPayload data routeParams -> List Head.Tag
|
||||
}
|
||||
-> Builder routeParams data
|
||||
prerenderWithFallback { data, head, pages } =
|
||||
preRenderWithFallback { data, head, pages } =
|
||||
WithData
|
||||
{ data = \_ -> data
|
||||
, staticRoutes = pages
|
||||
@ -328,12 +328,12 @@ prerenderWithFallback { data, head, pages } =
|
||||
|
||||
|
||||
{-| -}
|
||||
serverless :
|
||||
serverRender :
|
||||
{ data : ServerRequest.IsAvailable -> routeParams -> DataSource (PageServerResponse data)
|
||||
, head : StaticPayload data routeParams -> List Head.Tag
|
||||
}
|
||||
-> Builder routeParams data
|
||||
serverless { data, head } =
|
||||
serverRender { data, head } =
|
||||
WithData
|
||||
{ data = data
|
||||
, staticRoutes = DataSource.succeed []
|
||||
|
@ -41,7 +41,7 @@ function fileContentWithParams(
|
||||
pageModuleName,
|
||||
withParams,
|
||||
withState,
|
||||
serverless
|
||||
serverRender
|
||||
) {
|
||||
return `module Page.${pageModuleName} exposing (Model, Msg, Data, page)
|
||||
|
||||
@ -82,12 +82,12 @@ page : ${
|
||||
page =
|
||||
${
|
||||
serverless
|
||||
? `Page.serverless
|
||||
? `Page.serverRender
|
||||
{ head = head
|
||||
, data = data
|
||||
}`
|
||||
: withParams
|
||||
? `Page.prerender
|
||||
? `Page.preRender
|
||||
{ head = head
|
||||
, pages = pages
|
||||
, data = data
|
||||
|
@ -1,7 +1,7 @@
|
||||
module ApiRoute exposing
|
||||
( ApiRoute, ApiRouteBuilder, Response
|
||||
, capture, int, literal, single, slash, succeed
|
||||
, buildTimeRoutes, getBuildTimeRoutes, prerenderWithFallback, serverless
|
||||
, buildTimeRoutes, getBuildTimeRoutes, preRenderWithFallback, serverRender
|
||||
, toJson
|
||||
)
|
||||
|
||||
@ -16,7 +16,7 @@ DataSources dynamically.
|
||||
|
||||
@docs capture, int, literal, single, slash, succeed
|
||||
|
||||
@docs buildTimeRoutes, getBuildTimeRoutes, prerenderWithFallback, serverless
|
||||
@docs buildTimeRoutes, getBuildTimeRoutes, preRenderWithFallback, serverRender
|
||||
|
||||
|
||||
## Internals
|
||||
@ -73,8 +73,8 @@ stripTrailingSlash path =
|
||||
|
||||
|
||||
{-| -}
|
||||
serverless : ApiRouteBuilder (ServerRequest.IsAvailable -> DataSource ServerResponse) constructor -> ApiRoute Response
|
||||
serverless ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
|
||||
serverRender : ApiRouteBuilder (ServerRequest.IsAvailable -> DataSource ServerResponse) constructor -> ApiRoute Response
|
||||
serverRender ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
|
||||
ApiRoute
|
||||
{ regex = Regex.fromString ("^" ++ pattern ++ "$") |> Maybe.withDefault Regex.never
|
||||
, matchesToResponse =
|
||||
@ -101,8 +101,8 @@ serverless ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHan
|
||||
|
||||
|
||||
{-| -}
|
||||
prerenderWithFallback : (constructor -> DataSource (List (List String))) -> ApiRouteBuilder (DataSource ServerResponse) constructor -> ApiRoute Response
|
||||
prerenderWithFallback buildUrls ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
|
||||
preRenderWithFallback : (constructor -> DataSource (List (List String))) -> ApiRouteBuilder (DataSource ServerResponse) constructor -> ApiRoute Response
|
||||
preRenderWithFallback buildUrls ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
|
||||
let
|
||||
buildTimeRoutes__ : DataSource (List String)
|
||||
buildTimeRoutes__ =
|
||||
|
@ -84,7 +84,7 @@ all =
|
||||
|> DataSource.succeed
|
||||
)
|
||||
|> literal "no-dynamic-segments.json"
|
||||
|> ApiRoute.serverless
|
||||
|> ApiRoute.serverRender
|
||||
|> Internal.ApiRoute.toPattern
|
||||
|> Expect.equal (Pattern [ Pattern.Literal "no-dynamic-segments.json" ] Pattern.NoPendingSlash)
|
||||
, test "two literal segments" <|
|
||||
@ -97,7 +97,7 @@ all =
|
||||
|> ApiRoute.literal "api"
|
||||
|> ApiRoute.slash
|
||||
|> ApiRoute.literal "stars"
|
||||
|> ApiRoute.serverless
|
||||
|> ApiRoute.serverRender
|
||||
|> Internal.ApiRoute.toPattern
|
||||
|> Expect.equal
|
||||
(Pattern
|
||||
@ -147,7 +147,7 @@ all =
|
||||
|> ApiRoute.slash
|
||||
|> ApiRoute.capture
|
||||
|> ApiRoute.literal ".json"
|
||||
|> serverless
|
||||
|> serverRender
|
||||
|> Internal.ApiRoute.toPattern
|
||||
|> Expect.equal
|
||||
(Pattern
|
||||
|
Loading…
Reference in New Issue
Block a user