File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,26 @@ main = hakyll $ do
131131
132132 match " templates/*" $ compile templateBodyCompiler
133133
134+ create [" sitemap.xml" ] $ do
135+ route idRoute
136+ compile $ do
137+ let messages = loadAll " messages/*/*"
138+ let host = " https://errors.haskell.org"
139+ let pageCtx :: Context String
140+ pageCtx =
141+ mconcat
142+ [ modificationTimeField " lastmod" " %Y-%m-%d" ,
143+ constField " host" host
144+ ]
145+ let sitemapCtx =
146+ mconcat
147+ [ listField " entries" pageCtx messages,
148+ constField " host" host,
149+ defaultContext
150+ ]
151+ makeItem " "
152+ >>= loadAndApplyTemplate " templates/sitemap.xml" sitemapCtx
153+
134154 create [" api/errors.json" ] $ do
135155 route idRoute
136156 compile $ do
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <urlset xmlns =" http://www.sitemaps.org/schemas/sitemap/0.9" >
3+ $for(entries)$
4+ <url >
5+ <loc >$host$$url$</loc >
6+ <changefreq >weekly</changefreq >
7+ $if(lastmod)$<lastmod >$lastmod$</lastmod >$endif$
8+ <priority >0.8</priority >
9+ </url >
10+ $endfor$
11+ </urlset >
You can’t perform that action at this time.
0 commit comments