Generate routeToPath without Maybe.

This commit is contained in:
Dillon Kearns 2021-05-23 10:20:09 -07:00
parent 59f6f9012a
commit 366ca7ab80
5 changed files with 13 additions and 13 deletions

View File

@ -90,7 +90,7 @@ routes getStaticRoutes htmlToString =
allRoutes
|> List.map
(\route ->
{ path = Route.routeToPath (Just route) |> String.join "/"
{ path = Route.routeToPath route |> String.join "/"
, lastMod = Nothing
}
)
@ -112,7 +112,7 @@ postsDataSource =
{ title = article.title
, description = article.description
, url =
Just route
route
|> Route.routeToPath
|> String.join "/"
, categories = []

View File

@ -47,6 +47,7 @@
"elm-review": "^2.5.1",
"elm-test": "^0.19.1-revision7",
"elm-tooling": "^1.3.0",
"elm-verify-examples": "^5.0.0",
"mocha": "^8.4.0",
"typescript": "^4.2.4"
}
@ -1503,6 +1504,7 @@
"elm-review": "^2.5.1",
"elm-test": "^0.19.1-revision7",
"elm-tooling": "^1.3.0",
"elm-verify-examples": "^5.0.0",
"fs-extra": "^10.0.0",
"globby": "^11.0.3",
"gray-matter": "^4.0.3",

View File

@ -105,7 +105,7 @@ siteMap allRoutes =
|> List.filterMap identity
|> List.map
(\route ->
{ path = Route.routeToPath (Just route) |> String.join "/"
{ path = Route.routeToPath route |> String.join "/"
, lastMod = Nothing
}
)

View File

@ -32,7 +32,7 @@ all =
\route ->
let
asUrl =
Just route
route
|> Route.routeToPath
|> (\path ->
{ path = path |> String.join "/" }

View File

@ -383,7 +383,7 @@ main =
}
{ init = init Nothing
, urlToRoute = Route.urlToRoute
, routeToPath = Route.routeToPath
, routeToPath = \\route -> route |> Maybe.map Route.routeToPath |> Maybe.withDefault []
, site = Site.config
, getStaticRoutes = getStaticRoutes |> DataSource.map (List.map Just)
, handleRoute = handleRoute
@ -535,17 +535,15 @@ matchers =
{-| -}
routeToPath : Maybe Route -> List String
routeToPath maybeRoute =
case maybeRoute of
Nothing ->
[]
routeToPath : Route -> List String
routeToPath route =
case route of
${templates
.map(
(name) =>
`Just (${routeHelpers.routeVariant(
`${routeHelpers.routeVariant(
name
)} params) ->\n List.concat [ ${routeHelpers
)} params ->\n List.concat [ ${routeHelpers
.parseRouteParamsWithStatic(name)
.map((param) => {
switch (param.kind) {
@ -575,7 +573,7 @@ routeToPath maybeRoute =
toLink : (List (Attribute msg) -> tag) -> Route -> tag
toLink toAnchorTag route =
toAnchorTag
[ Attr.href ("/" ++ (routeToPath (Just route) |> String.join "/"))
[ Attr.href ("/" ++ (routeToPath route |> String.join "/"))
, Attr.attribute "elm-pages:prefetch" ""
]