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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.Port
@ -26,8 +26,8 @@ type alias RouteParams =
{}
page : StatelessRoute RouteParams Data
page =
route : StatelessRoute RouteParams Data
route =
RouteBuilder.single
{ head = head
, 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 Head
@ -24,8 +24,8 @@ type alias RouteParams =
{}
page : StatelessRoute RouteParams Data
page =
route : StatelessRoute RouteParams Data
route =
RouteBuilder.single
{ head = head
, 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 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

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

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

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

View File

@ -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)})`

View File

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