elm-pages-v3-beta/examples/trails/app/Site.elm
2023-01-01 14:45:54 -08:00

47 lines
971 B
Elm

module Site exposing (canonicalUrl, config)
import BackendTask exposing (BackendTask)
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 (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 })