templates: add sitemap.xml
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
24
src/site.hs
24
src/site.hs
@@ -13,8 +13,10 @@ import Text.Pandoc.Templates (Template, compileTemplate)
|
|||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = hakyllWith config $ do
|
main = hakyllWith config $ do
|
||||||
|
let
|
||||||
|
individualPatterns = fromList ["about.org", "contact.org", "links.org"]
|
||||||
|
|
||||||
match "images/logos/*" $ do
|
match "images/**" $ do
|
||||||
route idRoute
|
route idRoute
|
||||||
compile copyFileCompiler
|
compile copyFileCompiler
|
||||||
|
|
||||||
@@ -22,15 +24,11 @@ main = hakyllWith config $ do
|
|||||||
route idRoute
|
route idRoute
|
||||||
compile copyFileCompiler
|
compile copyFileCompiler
|
||||||
|
|
||||||
match "sitemap.xml" $ do
|
|
||||||
route idRoute
|
|
||||||
compile copyFileCompiler
|
|
||||||
|
|
||||||
match "css/*" $ do
|
match "css/*" $ do
|
||||||
route idRoute
|
route idRoute
|
||||||
compile compressCssCompiler
|
compile compressCssCompiler
|
||||||
|
|
||||||
match (fromList ["about.org", "contact.org", "links.org"]) $ do
|
match individualPatterns $ do
|
||||||
route $ setExtension "html"
|
route $ setExtension "html"
|
||||||
compile $
|
compile $
|
||||||
pandocCompiler
|
pandocCompiler
|
||||||
@@ -103,9 +101,18 @@ main = hakyllWith config $ do
|
|||||||
posts <- fmap (take 10) . recentFirst =<< loadAllSnapshots "posts/*" "content"
|
posts <- fmap (take 10) . recentFirst =<< loadAllSnapshots "posts/*" "content"
|
||||||
renderRss rssFeedConfiguration feedCtx posts
|
renderRss rssFeedConfiguration feedCtx posts
|
||||||
|
|
||||||
match "images/*" $ do
|
-- https://robertwpearce.com/hakyll-pt-2-generating-a-sitemap-xml-file.html
|
||||||
|
create ["sitemap.xml"] $ do
|
||||||
route idRoute
|
route idRoute
|
||||||
compile copyFileCompiler
|
compile $ do
|
||||||
|
posts <- recentFirst =<< loadAll "posts/*"
|
||||||
|
individualPages <- loadAll individualPatterns
|
||||||
|
let pages = posts <> individualPages
|
||||||
|
sitemapCtx =
|
||||||
|
listField "pages" (postCtx tags) (return pages)
|
||||||
|
<> defaultCtx
|
||||||
|
makeItem ""
|
||||||
|
>>= loadAndApplyTemplate "templates/sitemap.xml" sitemapCtx
|
||||||
|
|
||||||
match "templates/*" $ compile templateBodyCompiler
|
match "templates/*" $ compile templateBodyCompiler
|
||||||
|
|
||||||
@@ -133,6 +140,7 @@ postCtx tags =
|
|||||||
tagsField "tags" tags
|
tagsField "tags" tags
|
||||||
-- <> teaserFieldWithSeparator "((.tease.))" "teaser" "content"
|
-- <> teaserFieldWithSeparator "((.tease.))" "teaser" "content"
|
||||||
<> dateField "date" "%B %e, %Y"
|
<> dateField "date" "%B %e, %Y"
|
||||||
|
<> dateField "altdate" "%Y-%m-%d"
|
||||||
<> modificationTimeField "modified" "%B %e, %Y"
|
<> modificationTimeField "modified" "%B %e, %Y"
|
||||||
<> teaserField "teaser" "content"
|
<> teaserField "teaser" "content"
|
||||||
<> defaultCtx
|
<> defaultCtx
|
||||||
|
23
templates/sitemap.xml
Normal file
23
templates/sitemap.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset
|
||||||
|
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
||||||
|
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
|
||||||
|
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0"
|
||||||
|
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
|
||||||
|
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
|
||||||
|
>
|
||||||
|
<url>
|
||||||
|
<loc>https://$domain$</loc>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
$for(pages)$
|
||||||
|
<url>
|
||||||
|
<loc>https://$domain$$url$</loc>
|
||||||
|
<lastmod>$if(updated)$$updated$$else$$if(altdate)$$altdate$$endif$$endif$</lastmod>
|
||||||
|
<changefreq>weekly</changefreq>
|
||||||
|
<priority>0.8</priority>
|
||||||
|
</url>
|
||||||
|
$endfor$
|
||||||
|
</urlset>
|
Reference in New Issue
Block a user