diff --git a/examples/docs/app/Route/Blog.elm b/examples/docs/app/Route/Blog.elm index 94ab7f8b..21ef2e97 100644 --- a/examples/docs/app/Route/Blog.elm +++ b/examples/docs/app/Route/Blog.elm @@ -1,4 +1,4 @@ -module Route.Blog exposing (Data, Model, Msg, page) +module Route.Blog exposing (Data, Model, Msg, route) import Article import DataSource @@ -22,8 +22,8 @@ type alias Msg = () -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.single { head = head , data = data @@ -174,19 +174,19 @@ head staticPayload = link : Route.Route -> List (Attribute msg) -> List (Html msg) -> Html msg -link route attrs children = +link route_ attrs children = Route.toLink (\anchorAttrs -> a (List.map Attr.fromUnstyled anchorAttrs ++ attrs) children ) - route + route_ blogCard : ( Route, Article.ArticleMetadata ) -> Html msg -blogCard ( route, info ) = - link route +blogCard ( route_, info ) = + link route_ [ css [ Tw.flex , Tw.flex_col diff --git a/examples/docs/app/Route/Blog/Slug_.elm b/examples/docs/app/Route/Blog/Slug_.elm index 8f427dea..0ad34a3b 100644 --- a/examples/docs/app/Route/Blog/Slug_.elm +++ b/examples/docs/app/Route/Blog/Slug_.elm @@ -1,4 +1,4 @@ -module Route.Blog.Slug_ exposing (Data, Model, Msg, page) +module Route.Blog.Slug_ exposing (Data, Model, Msg, route) import Article import Cloudinary @@ -39,8 +39,8 @@ type alias RouteParams = { slug : String } -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.preRender { data = data , head = head @@ -234,11 +234,11 @@ type alias Data = data : RouteParams -> DataSource Data -data route = +data routeParams = MarkdownCodec.withFrontmatter Data frontmatterDecoder TailwindMarkdownRenderer.renderer - ("content/blog/" ++ route.slug ++ ".md") + ("content/blog/" ++ routeParams.slug ++ ".md") type alias ArticleMetadata = diff --git a/examples/docs/app/Route/Docs/Section__.elm b/examples/docs/app/Route/Docs/Section__.elm index cb625de1..ab889a40 100644 --- a/examples/docs/app/Route/Docs/Section__.elm +++ b/examples/docs/app/Route/Docs/Section__.elm @@ -1,4 +1,4 @@ -module Route.Docs.Section__ exposing (Data, Model, Msg, page) +module Route.Docs.Section__ exposing (Data, Model, Msg, route) import Css import Css.Global @@ -41,8 +41,8 @@ type alias RouteParams = { section : Maybe String } -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.preRender { head = head , pages = pages diff --git a/examples/docs/app/Route/Index.elm b/examples/docs/app/Route/Index.elm index 4c24f605..9d2a6974 100644 --- a/examples/docs/app/Route/Index.elm +++ b/examples/docs/app/Route/Index.elm @@ -1,4 +1,4 @@ -module Route.Index exposing (Data, Model, Msg, page) +module Route.Index exposing (Data, Model, Msg, route) import Css import DataSource exposing (DataSource) @@ -38,8 +38,8 @@ type alias Data = () -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.single { head = head , data = data @@ -116,13 +116,13 @@ landingView = , buttonLink = Route.Docs__Section__ { section = Nothing } , svgIcon = "M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" , code = - ( "src/Page/Repo/Name_.elm", """module Route.Repo.Name_ exposing (Data, Model, Msg, page) + ( "src/Page/Repo/Name_.elm", """module Route.Repo.Name_ exposing (Data, Model, Msg, route) type alias Data = Int type alias RouteParams = { name : String } -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = Page.preRender { head = head , pages = pages diff --git a/examples/docs/app/Route/Showcase.elm b/examples/docs/app/Route/Showcase.elm index 6d54e5e0..4d414982 100644 --- a/examples/docs/app/Route/Showcase.elm +++ b/examples/docs/app/Route/Showcase.elm @@ -1,4 +1,4 @@ -module Route.Showcase exposing (Data, Model, Msg, page) +module Route.Showcase exposing (Data, Model, Msg, route) import Css import DataSource @@ -29,8 +29,8 @@ type alias RouteParams = {} -page : StatefulRoute RouteParams Data Model Msg -page = +route : StatefulRoute RouteParams Data Model Msg +route = RouteBuilder.single { head = head , data = data diff --git a/examples/hello/app/Route/Blog/Slug_.elm b/examples/hello/app/Route/Blog/Slug_.elm index 813701f6..9cbe6044 100644 --- a/examples/hello/app/Route/Blog/Slug_.elm +++ b/examples/hello/app/Route/Blog/Slug_.elm @@ -1,4 +1,4 @@ -module Route.Blog.Slug_ exposing (Data, Model, Msg, page) +module Route.Blog.Slug_ exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import Head @@ -22,8 +22,8 @@ type alias RouteParams = { slug : String } -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.preRender { head = head , pages = pages diff --git a/examples/hello/app/Route/Index.elm b/examples/hello/app/Route/Index.elm index 9f123e27..a11bf614 100644 --- a/examples/hello/app/Route/Index.elm +++ b/examples/hello/app/Route/Index.elm @@ -1,4 +1,4 @@ -module Route.Index exposing (Data, Model, Msg, page) +module Route.Index exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import Head @@ -28,8 +28,8 @@ type alias Data = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.single { head = head , data = data diff --git a/examples/pokedex/app/Route/BasicAuth.elm b/examples/pokedex/app/Route/BasicAuth.elm index 8a18dd16..40a673a6 100644 --- a/examples/pokedex/app/Route/BasicAuth.elm +++ b/examples/pokedex/app/Route/BasicAuth.elm @@ -1,4 +1,4 @@ -module Route.BasicAuth exposing (Data, Model, Msg, page) +module Route.BasicAuth exposing (Data, Model, Msg, route) import Base64 import DataSource exposing (DataSource) @@ -24,8 +24,8 @@ type alias RouteParams = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.serverRender { head = head , data = data diff --git a/examples/pokedex/app/Route/FileUpload.elm b/examples/pokedex/app/Route/FileUpload.elm index c82be849..5e5c77b9 100644 --- a/examples/pokedex/app/Route/FileUpload.elm +++ b/examples/pokedex/app/Route/FileUpload.elm @@ -1,4 +1,4 @@ -module Route.FileUpload exposing (Data, Model, Msg, page) +module Route.FileUpload exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import Head @@ -26,8 +26,8 @@ type alias RouteParams = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.serverRender { head = head , data = data diff --git a/examples/pokedex/app/Route/Form.elm b/examples/pokedex/app/Route/Form.elm index beb0bb9b..7c2e8b1a 100644 --- a/examples/pokedex/app/Route/Form.elm +++ b/examples/pokedex/app/Route/Form.elm @@ -1,4 +1,4 @@ -module Route.Form exposing (Data, Model, Msg, page) +module Route.Form exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import Date exposing (Date) @@ -186,8 +186,8 @@ form user = ) -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.serverRender { head = head , data = data diff --git a/examples/pokedex/app/Route/FormEvent.elm b/examples/pokedex/app/Route/FormEvent.elm index 55d33993..2d00df65 100644 --- a/examples/pokedex/app/Route/FormEvent.elm +++ b/examples/pokedex/app/Route/FormEvent.elm @@ -1,4 +1,4 @@ -module Route.FormEvent exposing (Data, Model, Msg, page) +module Route.FormEvent exposing (Data, Model, Msg, route) import Browser.Navigation import DataSource exposing (DataSource) @@ -28,8 +28,8 @@ type alias RouteParams = {} -page : StatefulRoute RouteParams Data Model Msg -page = +route : StatefulRoute RouteParams Data Model Msg +route = RouteBuilder.single { head = head , data = data diff --git a/examples/pokedex/app/Route/Greet.elm b/examples/pokedex/app/Route/Greet.elm index 74dcc225..b34dbba3 100644 --- a/examples/pokedex/app/Route/Greet.elm +++ b/examples/pokedex/app/Route/Greet.elm @@ -1,4 +1,4 @@ -module Route.Greet exposing (Data, Model, Msg, page) +module Route.Greet exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import Dict exposing (Dict) @@ -30,8 +30,8 @@ type alias RouteParams = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.serverRender { head = head , data = data diff --git a/examples/pokedex/app/Route/Hex/Hex_.elm b/examples/pokedex/app/Route/Hex/Hex_.elm index 451076eb..a40fea89 100644 --- a/examples/pokedex/app/Route/Hex/Hex_.elm +++ b/examples/pokedex/app/Route/Hex/Hex_.elm @@ -1,4 +1,4 @@ -module Route.Hex.Hex_ exposing (Data, Model, Msg, page) +module Route.Hex.Hex_ exposing (Data, Model, Msg, route) import ColorHelpers import DataSource exposing (DataSource) @@ -21,8 +21,8 @@ type alias Data = ColorHelpers.Data -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.preRenderWithFallback { head = ColorHelpers.head toCssVal , pages = pages diff --git a/examples/pokedex/app/Route/Index.elm b/examples/pokedex/app/Route/Index.elm index b47e07af..94a10bff 100644 --- a/examples/pokedex/app/Route/Index.elm +++ b/examples/pokedex/app/Route/Index.elm @@ -1,4 +1,4 @@ -module Route.Index exposing (Data, Model, Msg, page) +module Route.Index exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import DataSource.Env as Env @@ -28,8 +28,8 @@ type alias RouteParams = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.single { head = head , data = data diff --git a/examples/pokedex/app/Route/Login.elm b/examples/pokedex/app/Route/Login.elm index 18184f0d..55e19ebd 100644 --- a/examples/pokedex/app/Route/Login.elm +++ b/examples/pokedex/app/Route/Login.elm @@ -1,4 +1,4 @@ -module Route.Login exposing (Data, Model, Msg, page) +module Route.Login exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import Dict exposing (Dict) @@ -29,8 +29,8 @@ type alias RouteParams = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.serverRender { head = head , data = data diff --git a/examples/pokedex/app/Route/Named/Color_.elm b/examples/pokedex/app/Route/Named/Color_.elm index 8d973f3d..fc4c7ba9 100644 --- a/examples/pokedex/app/Route/Named/Color_.elm +++ b/examples/pokedex/app/Route/Named/Color_.elm @@ -1,4 +1,4 @@ -module Route.Named.Color_ exposing (Data, Model, Msg, page) +module Route.Named.Color_ exposing (Data, Model, Msg, route) import ColorHelpers import DataSource exposing (DataSource) @@ -21,8 +21,8 @@ type alias Data = ColorHelpers.Data -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.preRenderWithFallback { head = ColorHelpers.head toCssVal , pages = pages diff --git a/examples/pokedex/app/Route/PokedexNumber_.elm b/examples/pokedex/app/Route/PokedexNumber_.elm index bba1ef22..c4cfe1ff 100644 --- a/examples/pokedex/app/Route/PokedexNumber_.elm +++ b/examples/pokedex/app/Route/PokedexNumber_.elm @@ -1,4 +1,4 @@ -module Route.PokedexNumber_ exposing (Data, Model, Msg, page) +module Route.PokedexNumber_ exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import DataSource.Http @@ -27,8 +27,8 @@ type alias RouteParams = { pokedexNumber : String } -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.preRenderWithFallback { head = head , pages = pages diff --git a/examples/pokedex/app/Route/PortTest.elm b/examples/pokedex/app/Route/PortTest.elm index 7ae1ab4b..59be14fb 100644 --- a/examples/pokedex/app/Route/PortTest.elm +++ b/examples/pokedex/app/Route/PortTest.elm @@ -1,4 +1,4 @@ -module Route.PortTest exposing (Data, Model, Msg, page) +module Route.PortTest exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import DataSource.Port @@ -26,8 +26,8 @@ type alias RouteParams = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.single { head = head , data = data diff --git a/examples/pokedex/app/Route/RedirectLinks.elm b/examples/pokedex/app/Route/RedirectLinks.elm index d6236646..e85980f1 100644 --- a/examples/pokedex/app/Route/RedirectLinks.elm +++ b/examples/pokedex/app/Route/RedirectLinks.elm @@ -1,4 +1,4 @@ -module Route.RedirectLinks exposing (Data, Model, Msg, page) +module Route.RedirectLinks exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import Head @@ -24,8 +24,8 @@ type alias RouteParams = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.single { head = head , data = data diff --git a/examples/pokedex/app/Route/Rgb/Red_/Green_/Blue_.elm b/examples/pokedex/app/Route/Rgb/Red_/Green_/Blue_.elm index a23ea580..d6c15982 100644 --- a/examples/pokedex/app/Route/Rgb/Red_/Green_/Blue_.elm +++ b/examples/pokedex/app/Route/Rgb/Red_/Green_/Blue_.elm @@ -1,4 +1,4 @@ -module Route.Rgb.Red_.Green_.Blue_ exposing (Data, Model, Msg, page) +module Route.Rgb.Red_.Green_.Blue_ exposing (Data, Model, Msg, route) import ColorHelpers import DataSource exposing (DataSource) @@ -17,8 +17,8 @@ type alias RouteParams = { red : String, green : String, blue : String } -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.preRenderWithFallback { head = ColorHelpers.head toCssVal , pages = pages diff --git a/examples/pokedex/app/Route/Secret.elm b/examples/pokedex/app/Route/Secret.elm index 98d96a3d..2b39b5f7 100644 --- a/examples/pokedex/app/Route/Secret.elm +++ b/examples/pokedex/app/Route/Secret.elm @@ -1,4 +1,4 @@ -module Route.Secret exposing (Data, Model, Msg, page) +module Route.Secret exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import DataSource.File @@ -28,8 +28,8 @@ type alias RouteParams = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.serverRender { head = head , data = data diff --git a/examples/pokedex/app/Route/TailwindForm.elm b/examples/pokedex/app/Route/TailwindForm.elm index 11fa8e3c..ed929654 100644 --- a/examples/pokedex/app/Route/TailwindForm.elm +++ b/examples/pokedex/app/Route/TailwindForm.elm @@ -1,4 +1,4 @@ -module Route.TailwindForm exposing (Data, Model, Msg, page) +module Route.TailwindForm exposing (Data, Model, Msg, route) import Browser.Dom import Css exposing (Color) @@ -542,8 +542,8 @@ cancelButton = [ Html.text "Cancel" ] -page : StatefulRoute RouteParams Data Model Msg -page = +route : StatefulRoute RouteParams Data Model Msg +route = RouteBuilder.serverRender { head = head , data = data diff --git a/examples/pokedex/app/Route/Time.elm b/examples/pokedex/app/Route/Time.elm index b2b7f242..83c1dc47 100644 --- a/examples/pokedex/app/Route/Time.elm +++ b/examples/pokedex/app/Route/Time.elm @@ -1,4 +1,4 @@ -module Route.Time exposing (Data, Model, Msg, page) +module Route.Time exposing (Data, Model, Msg, route) import DataSource exposing (DataSource) import Dict exposing (Dict) @@ -27,8 +27,8 @@ type alias RouteParams = {} -page : StatelessRoute RouteParams Data -page = +route : StatelessRoute RouteParams Data +route = RouteBuilder.serverRender { head = head , data = data diff --git a/examples/pokedex/app/Route/Todos.elm b/examples/pokedex/app/Route/Todos.elm index a5528eb0..a4644a48 100644 --- a/examples/pokedex/app/Route/Todos.elm +++ b/examples/pokedex/app/Route/Todos.elm @@ -1,4 +1,4 @@ -module Route.Todos exposing (Data, Model, Msg, page) +module Route.Todos exposing (Data, Model, Msg, route) import Api.InputObject import Api.Mutation @@ -44,8 +44,8 @@ type alias RouteParams = {} -page : StatefulRoute RouteParams Data Model Msg -page = +route : StatefulRoute RouteParams Data Model Msg +route = RouteBuilder.serverRender { head = head , data = data diff --git a/generator/src/generate-template-module-connector.js b/generator/src/generate-template-module-connector.js index c11a50fe..8fe134ab 100644 --- a/generator/src/generate-template-module-connector.js +++ b/generator/src/generate-template-module-connector.js @@ -162,7 +162,7 @@ view page maybePageUrl globalData pageData = \\model -> case model.page of Model${pathNormalizedName(name)} subModel -> - Route.${moduleName(name)}.page.view + Route.${moduleName(name)}.route.view maybePageUrl model.global subModel @@ -181,7 +181,7 @@ view page maybePageUrl globalData pageData = , head = ${ phase === "browser" ? "[]" - : `Route.${moduleName(name)}.page.head + : `Route.${moduleName(name)}.route.head { data = data , sharedData = globalData , routeParams = ${emptyRouteParams(name) ? "{}" : "s"} @@ -243,7 +243,7 @@ init currentGlobalModel userFlags sharedData pageData navigationKey maybePagePat }, justPath ), Data${pathNormalizedName( name )} thisPageData ) -> - Route.${moduleName(name)}.page.init + Route.${moduleName(name)}.route.init (Maybe.andThen .pageUrl maybePagePath) sharedModel { data = thisPageData @@ -346,7 +346,7 @@ update sharedData pageData navigationKey msg model = name, "routeParams" )}, pageUrl, justPage ) ) -> - Route.${moduleName(name)}.page.update + Route.${moduleName(name)}.route.update pageUrl { data = thisPageData , sharedData = sharedData @@ -395,7 +395,7 @@ templateSubscriptions route path model = name, "routeParams" )} ) -> - Route.${moduleName(name)}.page.subscriptions + Route.${moduleName(name)}.route.subscriptions Nothing -- TODO wire through value ${routeHelpers.referenceRouteParams(name, "routeParams")} path @@ -596,7 +596,7 @@ dataForRoute route = : `(Route.${routeHelpers.routeVariant(name)} routeParams)` } ->\n Route.${name.join( "." - )}.page.data ${routeHelpers.referenceRouteParams( + )}.route.data ${routeHelpers.referenceRouteParams( name, "routeParams" )} @@ -622,7 +622,7 @@ handleRoute maybeRoute = : " routeParams" }) ->\n Route.${name.join( "." - )}.page.handleRoute { moduleName = [ ${name + )}.route.handleRoute { moduleName = [ ${name .map((part) => `"${part}"`) .join(", ")} ], routePattern = ${routeHelpers.toElmPathPattern( name @@ -695,7 +695,7 @@ routePatterns = .map((name) => { return `{ kind = Route.${moduleName( name - )}.page.kind, pathPattern = "${routeHelpers.toPathPattern( + )}.route.kind, pathPattern = "${routeHelpers.toPathPattern( name )}" }`; }) @@ -749,7 +749,7 @@ getStaticRoutes = .map((name) => { return `Route.${moduleName( name - )}.page.staticRoutes |> DataSource.map (List.map ${ + )}.route.staticRoutes |> DataSource.map (List.map ${ emptyRouteParams(name) ? `(\\_ -> Route.${pathNormalizedName(name)}))` : `Route.${pathNormalizedName(name)})` diff --git a/src/Pages/Review/NoContractViolations.elm b/src/Pages/Review/NoContractViolations.elm index 265143d4..17f5255a 100644 --- a/src/Pages/Review/NoContractViolations.elm +++ b/src/Pages/Review/NoContractViolations.elm @@ -86,7 +86,7 @@ moduleDefinitionVisitor node _ = Exposing.Explicit exposedValues -> if isRouteModule then - case Set.diff (Set.fromList [ "Data", "Msg", "Model", "page" ]) (exposedNames exposedValues) |> Set.toList of + case Set.diff (Set.fromList [ "Data", "Msg", "Model", "route" ]) (exposedNames exposedValues) |> Set.toList of [] -> ( [] , { moduleName = Node.value node |> Module.moduleName