dillonkearns/elm-pages-v3-beta/1.0.0

NOTE: the latest version is 21.0.0

ApiRoute

ApiRoute's are defined in src/Api.elm and are a way to generate files, like RSS feeds, sitemaps, or any text-based file that you output with an Elm function! You get access to a DataSource so you can pull in HTTP data, etc. Because ApiRoutes don't hydrate into Elm apps (like pages in elm-pages do), you can pull in as much data as you want in the DataSource for your ApiRoutes, and it won't effect the payload size. Instead, the size of an ApiRoute is just the content you output for that route.

In a future release, ApiRoutes may be able to run at request-time in a serverless function, allowing you to use pure Elm code to create dynamic APIs, and even pulling in data from DataSources dynamically.

type alias ApiRoute response =
ApiRoute response
type alias ApiRouteBuilder a constructor =
ApiRouteBuilder a constructor
type alias Response =
Value
ApiRouteBuilder (String -> a) constructor
-> ApiRouteBuilder a (String -> constructor)
String
-> ApiRouteBuilder a constructor
-> ApiRouteBuilder a constructor
slash : ApiRouteBuilder a constructor -> ApiRouteBuilder a constructor
succeed : a -> ApiRouteBuilder a (List String)

Pre-Rendering

ApiRouteBuilder (DataSource String) (List String)
-> ApiRoute Response
(constructor -> DataSource (List (List String)))
-> ApiRouteBuilder (DataSource String) constructor
-> ApiRoute Response

Server Rendering

(constructor -> DataSource (List (List String)))
-> ApiRouteBuilder (DataSource (Response Never Never)) constructor
-> ApiRoute Response
ApiRouteBuilder
(Parser (DataSource (Response Never Never)))
constructor
-> ApiRoute Response

Including Head Tags

withGlobalHeadTags : DataSource (List Tag) -> ApiRoute response -> ApiRoute response

Include head tags on every page's HTML.

Internals

toJson : ApiRoute response -> Value

Turn the route into a pattern in JSON format. For internal uses.

getBuildTimeRoutes : ApiRoute response -> DataSource (List String)

For internal use by generated code. Not so useful in user-land.

getGlobalHeadTagsDataSource : ApiRoute response -> Maybe (DataSource (List Tag))