add sitemap.xml

This commit is contained in:
nek0 2017-12-03 04:00:05 +01:00
parent d44978d713
commit 5c11de8399
3 changed files with 30 additions and 0 deletions

View File

@ -1,3 +1,4 @@
User-agent: *
Sitemap: https://nek0.eu/sitemap.xml
Disallow: /imprint.html
Disallow: /contact.html

View File

@ -138,6 +138,24 @@ main =
>>= fmap (take 10) . recentFirst
>>= renderRss feedConf feedCtx
create ["sitemap.xml"] $ do
route idRoute
compile $ do
rposts <- loadAll "site/**/*.md"
rsites <- loadAll "site/*.md"
-- rtxts <- loadAll "site/*.txt"
-- rascs <- loadAll "site/*.asc"
let sites = return (rposts ++ rsites)
let sitemapCtx = mconcat
[ listField "entries"
(postCtx tags <> constField "host" "https://nek0.eu/")
sites
, constField "host" "https://nek0.eu/"
, defaultContext
]
makeItem ""
>>= loadAndApplyTemplate "templates/sitemap.xml" sitemapCtx
--------------------------------------------------------------------------------
sortIdentifiersByDate :: [Identifier] -> [Identifier]

11
templates/sitemap.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
$for(entries)$
<url>
<loc>$host$$url$</loc>
<changefreq>monthly</changefreq>
$if(lastmod)$<lastmod>$lastmod$</lastmod>$endif$
<priority>0.8</priority>
</url>
$endfor$
</urlset>