elm-pages-v3-beta/examples/pokedex/app/Site.elm
2023-01-16 17:48:46 -08:00

48 lines
1022 B
Elm

module Site exposing (canonicalUrl, config)
import BackendTask exposing (BackendTask)
import FatalError exposing (FatalError)
import Head
import Route exposing (Route)
import SiteConfig exposing (SiteConfig)
import Sitemap
type alias Data =
()
config : SiteConfig
config =
{ canonicalUrl = canonicalUrl
, head = head
}
canonicalUrl : String
canonicalUrl =
"https://elm-pages.com"
head : BackendTask FatalError (List Head.Tag)
head =
[ Head.sitemapLink "/sitemap.xml"
]
|> BackendTask.succeed
siteMap :
List (Maybe Route)
-> { path : List String, content : String }
siteMap allRoutes =
allRoutes
|> List.filterMap identity
|> List.map
(\route ->
{ path = Route.routeToPath route |> String.join "/"
, lastMod = Nothing
}
)
|> Sitemap.build { siteUrl = "https://elm-pages.com" }
|> (\sitemapXmlString -> { path = [ "sitemap.xml" ], content = sitemapXmlString })