From: Lucian Mogosanu Date: Sat, 20 Jul 2013 08:42:16 +0000 (+0300) Subject: add archive X-Git-Tag: v0.1~32 X-Git-Url: https://git.mogosanu.ro/?a=commitdiff_plain;h=47aebd6f7a2fa0e8b3d7cfb32e3e17521001a2ef;p=thetarpit.git add archive --- diff --git a/site.hs b/site.hs index 85dd540..768fc3c 100644 --- a/site.hs +++ b/site.hs @@ -8,6 +8,7 @@ main = hakyll $ do match "css/*" compileCss match "posts/*" compilePosts match (fromList ["about.markdown"]) compilePages + create ["archive.html"] compileArchive match "templates/*" $ compile templateCompiler compileIndex :: Rules () @@ -43,5 +44,19 @@ compilePages = do >>= loadAndApplyTemplate "templates/default.html" defaultContext >>= relativizeUrls +compileArchive :: Rules () +compileArchive = do + route idRoute + compile $ do + posts <- loadAll "posts/*" >>= recentFirst + let archiveCtx = + listField "posts" postCtx (return posts) `mappend` + constField "title" "Archive" `mappend` + defaultContext + makeItem "" + >>= loadAndApplyTemplate "templates/archive.html" archiveCtx + >>= loadAndApplyTemplate "templates/default.html" archiveCtx + >>= relativizeUrls + postCtx :: Context String postCtx = dateField "date" "%B %e, %Y" `mappend` defaultContext diff --git a/templates/archive.html b/templates/archive.html new file mode 100644 index 0000000..4d91f5b --- /dev/null +++ b/templates/archive.html @@ -0,0 +1,2 @@ +Posts from The Tar Pit: +$partial("templates/post-list.html")$ diff --git a/templates/default.html b/templates/default.html index 4f248a0..781c585 100644 --- a/templates/default.html +++ b/templates/default.html @@ -16,7 +16,7 @@