Change exported value from page -> route from Route Modules.

This commit is contained in:
Dillon Kearns 2022-03-05 10:35:17 -08:00
parent ce69b83b8a
commit b7495d73bb
26 changed files with 91 additions and 91 deletions

View File

@ -1,4 +1,4 @@
module Route.Blog exposing (Data, Model, Msg, page) module Route.Blog exposing (Data, Model, Msg, route)
import Article import Article
import DataSource import DataSource
@ -22,8 +22,8 @@ type alias Msg =
() ()
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.single RouteBuilder.single
{ head = head { head = head
, data = data , data = data
@ -174,19 +174,19 @@ head staticPayload =
link : Route.Route -> List (Attribute msg) -> List (Html msg) -> Html msg link : Route.Route -> List (Attribute msg) -> List (Html msg) -> Html msg
link route attrs children = link route_ attrs children =
Route.toLink Route.toLink
(\anchorAttrs -> (\anchorAttrs ->
a a
(List.map Attr.fromUnstyled anchorAttrs ++ attrs) (List.map Attr.fromUnstyled anchorAttrs ++ attrs)
children children
) )
route route_
blogCard : ( Route, Article.ArticleMetadata ) -> Html msg blogCard : ( Route, Article.ArticleMetadata ) -> Html msg
blogCard ( route, info ) = blogCard ( route_, info ) =
link route link route_
[ css [ css
[ Tw.flex [ Tw.flex
, Tw.flex_col , Tw.flex_col

View File

@ -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 Article
import Cloudinary import Cloudinary
@ -39,8 +39,8 @@ type alias RouteParams =
{ slug : String } { slug : String }
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.preRender RouteBuilder.preRender
{ data = data { data = data
, head = head , head = head
@ -234,11 +234,11 @@ type alias Data =
data : RouteParams -> DataSource Data data : RouteParams -> DataSource Data
data route = data routeParams =
MarkdownCodec.withFrontmatter Data MarkdownCodec.withFrontmatter Data
frontmatterDecoder frontmatterDecoder
TailwindMarkdownRenderer.renderer TailwindMarkdownRenderer.renderer
("content/blog/" ++ route.slug ++ ".md") ("content/blog/" ++ routeParams.slug ++ ".md")
type alias ArticleMetadata = type alias ArticleMetadata =

View File

@ -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
import Css.Global import Css.Global
@ -41,8 +41,8 @@ type alias RouteParams =
{ section : Maybe String } { section : Maybe String }
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.preRender RouteBuilder.preRender
{ head = head { head = head
, pages = pages , pages = pages

View File

@ -1,4 +1,4 @@
module Route.Index exposing (Data, Model, Msg, page) module Route.Index exposing (Data, Model, Msg, route)
import Css import Css
import DataSource exposing (DataSource) import DataSource exposing (DataSource)
@ -38,8 +38,8 @@ type alias Data =
() ()
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.single RouteBuilder.single
{ head = head { head = head
, data = data , data = data
@ -116,13 +116,13 @@ landingView =
, buttonLink = Route.Docs__Section__ { section = Nothing } , 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" , 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 = , 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 Data = Int
type alias RouteParams = { name : String } type alias RouteParams = { name : String }
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
Page.preRender Page.preRender
{ head = head { head = head
, pages = pages , pages = pages

View File

@ -1,4 +1,4 @@
module Route.Showcase exposing (Data, Model, Msg, page) module Route.Showcase exposing (Data, Model, Msg, route)
import Css import Css
import DataSource import DataSource
@ -29,8 +29,8 @@ type alias RouteParams =
{} {}
page : StatefulRoute RouteParams Data Model Msg route : StatefulRoute RouteParams Data Model Msg
page = route =
RouteBuilder.single RouteBuilder.single
{ head = head { head = head
, data = data , data = data

View File

@ -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 DataSource exposing (DataSource)
import Head import Head
@ -22,8 +22,8 @@ type alias RouteParams =
{ slug : String } { slug : String }
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.preRender RouteBuilder.preRender
{ head = head { head = head
, pages = pages , pages = pages

View File

@ -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 exposing (DataSource)
import Head import Head
@ -28,8 +28,8 @@ type alias Data =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.single RouteBuilder.single
{ head = head { head = head
, data = data , data = data

View File

@ -1,4 +1,4 @@
module Route.BasicAuth exposing (Data, Model, Msg, page) module Route.BasicAuth exposing (Data, Model, Msg, route)
import Base64 import Base64
import DataSource exposing (DataSource) import DataSource exposing (DataSource)
@ -24,8 +24,8 @@ type alias RouteParams =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.serverRender RouteBuilder.serverRender
{ head = head { head = head
, data = data , data = data

View File

@ -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 DataSource exposing (DataSource)
import Head import Head
@ -26,8 +26,8 @@ type alias RouteParams =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.serverRender RouteBuilder.serverRender
{ head = head { head = head
, data = data , data = data

View File

@ -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 DataSource exposing (DataSource)
import Date exposing (Date) import Date exposing (Date)
@ -186,8 +186,8 @@ form user =
) )
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.serverRender RouteBuilder.serverRender
{ head = head { head = head
, data = data , data = data

View File

@ -1,4 +1,4 @@
module Route.FormEvent exposing (Data, Model, Msg, page) module Route.FormEvent exposing (Data, Model, Msg, route)
import Browser.Navigation import Browser.Navigation
import DataSource exposing (DataSource) import DataSource exposing (DataSource)
@ -28,8 +28,8 @@ type alias RouteParams =
{} {}
page : StatefulRoute RouteParams Data Model Msg route : StatefulRoute RouteParams Data Model Msg
page = route =
RouteBuilder.single RouteBuilder.single
{ head = head { head = head
, data = data , data = data

View File

@ -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 DataSource exposing (DataSource)
import Dict exposing (Dict) import Dict exposing (Dict)
@ -30,8 +30,8 @@ type alias RouteParams =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.serverRender RouteBuilder.serverRender
{ head = head { head = head
, data = data , data = data

View File

@ -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 ColorHelpers
import DataSource exposing (DataSource) import DataSource exposing (DataSource)
@ -21,8 +21,8 @@ type alias Data =
ColorHelpers.Data ColorHelpers.Data
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.preRenderWithFallback RouteBuilder.preRenderWithFallback
{ head = ColorHelpers.head toCssVal { head = ColorHelpers.head toCssVal
, pages = pages , pages = pages

View File

@ -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 exposing (DataSource)
import DataSource.Env as Env import DataSource.Env as Env
@ -28,8 +28,8 @@ type alias RouteParams =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.single RouteBuilder.single
{ head = head { head = head
, data = data , data = data

View File

@ -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 DataSource exposing (DataSource)
import Dict exposing (Dict) import Dict exposing (Dict)
@ -29,8 +29,8 @@ type alias RouteParams =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.serverRender RouteBuilder.serverRender
{ head = head { head = head
, data = data , data = data

View File

@ -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 ColorHelpers
import DataSource exposing (DataSource) import DataSource exposing (DataSource)
@ -21,8 +21,8 @@ type alias Data =
ColorHelpers.Data ColorHelpers.Data
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.preRenderWithFallback RouteBuilder.preRenderWithFallback
{ head = ColorHelpers.head toCssVal { head = ColorHelpers.head toCssVal
, pages = pages , pages = pages

View File

@ -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 exposing (DataSource)
import DataSource.Http import DataSource.Http
@ -27,8 +27,8 @@ type alias RouteParams =
{ pokedexNumber : String } { pokedexNumber : String }
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.preRenderWithFallback RouteBuilder.preRenderWithFallback
{ head = head { head = head
, pages = pages , pages = pages

View File

@ -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 exposing (DataSource)
import DataSource.Port import DataSource.Port
@ -26,8 +26,8 @@ type alias RouteParams =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.single RouteBuilder.single
{ head = head { head = head
, data = data , data = data

View File

@ -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 DataSource exposing (DataSource)
import Head import Head
@ -24,8 +24,8 @@ type alias RouteParams =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.single RouteBuilder.single
{ head = head { head = head
, data = data , data = data

View File

@ -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 ColorHelpers
import DataSource exposing (DataSource) import DataSource exposing (DataSource)
@ -17,8 +17,8 @@ type alias RouteParams =
{ red : String, green : String, blue : String } { red : String, green : String, blue : String }
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.preRenderWithFallback RouteBuilder.preRenderWithFallback
{ head = ColorHelpers.head toCssVal { head = ColorHelpers.head toCssVal
, pages = pages , pages = pages

View File

@ -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 exposing (DataSource)
import DataSource.File import DataSource.File
@ -28,8 +28,8 @@ type alias RouteParams =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.serverRender RouteBuilder.serverRender
{ head = head { head = head
, data = data , data = data

View File

@ -1,4 +1,4 @@
module Route.TailwindForm exposing (Data, Model, Msg, page) module Route.TailwindForm exposing (Data, Model, Msg, route)
import Browser.Dom import Browser.Dom
import Css exposing (Color) import Css exposing (Color)
@ -542,8 +542,8 @@ cancelButton =
[ Html.text "Cancel" ] [ Html.text "Cancel" ]
page : StatefulRoute RouteParams Data Model Msg route : StatefulRoute RouteParams Data Model Msg
page = route =
RouteBuilder.serverRender RouteBuilder.serverRender
{ head = head { head = head
, data = data , data = data

View File

@ -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 DataSource exposing (DataSource)
import Dict exposing (Dict) import Dict exposing (Dict)
@ -27,8 +27,8 @@ type alias RouteParams =
{} {}
page : StatelessRoute RouteParams Data route : StatelessRoute RouteParams Data
page = route =
RouteBuilder.serverRender RouteBuilder.serverRender
{ head = head { head = head
, data = data , data = data

View File

@ -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.InputObject
import Api.Mutation import Api.Mutation
@ -44,8 +44,8 @@ type alias RouteParams =
{} {}
page : StatefulRoute RouteParams Data Model Msg route : StatefulRoute RouteParams Data Model Msg
page = route =
RouteBuilder.serverRender RouteBuilder.serverRender
{ head = head { head = head
, data = data , data = data

View File

@ -162,7 +162,7 @@ view page maybePageUrl globalData pageData =
\\model -> \\model ->
case model.page of case model.page of
Model${pathNormalizedName(name)} subModel -> Model${pathNormalizedName(name)} subModel ->
Route.${moduleName(name)}.page.view Route.${moduleName(name)}.route.view
maybePageUrl maybePageUrl
model.global model.global
subModel subModel
@ -181,7 +181,7 @@ view page maybePageUrl globalData pageData =
, head = ${ , head = ${
phase === "browser" phase === "browser"
? "[]" ? "[]"
: `Route.${moduleName(name)}.page.head : `Route.${moduleName(name)}.route.head
{ data = data { data = data
, sharedData = globalData , sharedData = globalData
, routeParams = ${emptyRouteParams(name) ? "{}" : "s"} , routeParams = ${emptyRouteParams(name) ? "{}" : "s"}
@ -243,7 +243,7 @@ init currentGlobalModel userFlags sharedData pageData navigationKey maybePagePat
}, justPath ), Data${pathNormalizedName( }, justPath ), Data${pathNormalizedName(
name name
)} thisPageData ) -> )} thisPageData ) ->
Route.${moduleName(name)}.page.init Route.${moduleName(name)}.route.init
(Maybe.andThen .pageUrl maybePagePath) (Maybe.andThen .pageUrl maybePagePath)
sharedModel sharedModel
{ data = thisPageData { data = thisPageData
@ -346,7 +346,7 @@ update sharedData pageData navigationKey msg model =
name, name,
"routeParams" "routeParams"
)}, pageUrl, justPage ) ) -> )}, pageUrl, justPage ) ) ->
Route.${moduleName(name)}.page.update Route.${moduleName(name)}.route.update
pageUrl pageUrl
{ data = thisPageData { data = thisPageData
, sharedData = sharedData , sharedData = sharedData
@ -395,7 +395,7 @@ templateSubscriptions route path model =
name, name,
"routeParams" "routeParams"
)} ) -> )} ) ->
Route.${moduleName(name)}.page.subscriptions Route.${moduleName(name)}.route.subscriptions
Nothing -- TODO wire through value Nothing -- TODO wire through value
${routeHelpers.referenceRouteParams(name, "routeParams")} ${routeHelpers.referenceRouteParams(name, "routeParams")}
path path
@ -596,7 +596,7 @@ dataForRoute route =
: `(Route.${routeHelpers.routeVariant(name)} routeParams)` : `(Route.${routeHelpers.routeVariant(name)} routeParams)`
} ->\n Route.${name.join( } ->\n Route.${name.join(
"." "."
)}.page.data ${routeHelpers.referenceRouteParams( )}.route.data ${routeHelpers.referenceRouteParams(
name, name,
"routeParams" "routeParams"
)} )}
@ -622,7 +622,7 @@ handleRoute maybeRoute =
: " routeParams" : " routeParams"
}) ->\n Route.${name.join( }) ->\n Route.${name.join(
"." "."
)}.page.handleRoute { moduleName = [ ${name )}.route.handleRoute { moduleName = [ ${name
.map((part) => `"${part}"`) .map((part) => `"${part}"`)
.join(", ")} ], routePattern = ${routeHelpers.toElmPathPattern( .join(", ")} ], routePattern = ${routeHelpers.toElmPathPattern(
name name
@ -695,7 +695,7 @@ routePatterns =
.map((name) => { .map((name) => {
return `{ kind = Route.${moduleName( return `{ kind = Route.${moduleName(
name name
)}.page.kind, pathPattern = "${routeHelpers.toPathPattern( )}.route.kind, pathPattern = "${routeHelpers.toPathPattern(
name name
)}" }`; )}" }`;
}) })
@ -749,7 +749,7 @@ getStaticRoutes =
.map((name) => { .map((name) => {
return `Route.${moduleName( return `Route.${moduleName(
name name
)}.page.staticRoutes |> DataSource.map (List.map ${ )}.route.staticRoutes |> DataSource.map (List.map ${
emptyRouteParams(name) emptyRouteParams(name)
? `(\\_ -> Route.${pathNormalizedName(name)}))` ? `(\\_ -> Route.${pathNormalizedName(name)}))`
: `Route.${pathNormalizedName(name)})` : `Route.${pathNormalizedName(name)})`

View File

@ -86,7 +86,7 @@ moduleDefinitionVisitor node _ =
Exposing.Explicit exposedValues -> Exposing.Explicit exposedValues ->
if isRouteModule then 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 , { moduleName = Node.value node |> Module.moduleName