Skip to content

Commit 55a6291

Browse files
committed
Initial draft of sitemap
1 parent 9404c34 commit 55a6291

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

message-index/site.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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>

0 commit comments

Comments
 (0)