mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-24 06:54:03 +03:00
Generate routeToPath without Maybe.
This commit is contained in:
parent
59f6f9012a
commit
366ca7ab80
@ -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 = []
|
||||
|
2
examples/routing/package-lock.json
generated
2
examples/routing/package-lock.json
generated
@ -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",
|
||||
|
@ -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
|
||||
}
|
||||
)
|
||||
|
@ -32,7 +32,7 @@ all =
|
||||
\route ->
|
||||
let
|
||||
asUrl =
|
||||
Just route
|
||||
route
|
||||
|> Route.routeToPath
|
||||
|> (\path ->
|
||||
{ path = path |> String.join "/" }
|
||||
|
@ -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" ""
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user