diff options
| author | Carlos Sosa <gnusosa@gnusosa.net> | 2019-08-11 17:18:45 -0700 |
|---|---|---|
| committer | Carlos Sosa <gnusosa@gnusosa.net> | 2019-08-11 17:18:45 -0700 |
| commit | e6f4ca04ba1e8a8f2ae299e5a2ec09f26a89e736 (patch) | |
| tree | e2df289f8a6bf08ccda5b32d857ef63e6c6db127 /site.hs | |
| parent | e48a9d406fbd5489dc25bcdd92b1df2b0c862105 (diff) | |
Add log entries, and move to better context functions
Diffstat (limited to 'site.hs')
| -rw-r--r-- | site.hs | 52 |
1 files changed, 28 insertions, 24 deletions
@@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} -import Data.Monoid (mappend) +import Data.Monoid ((<>)) import Hakyll @@ -21,51 +21,55 @@ main = hakyll $ do >>= loadAndApplyTemplate "templates/default.html" defaultContext >>= relativizeUrls - match "log/*.markdown" $ do + match "log/*.org" $ do route $ setExtension "html" compile $ pandocCompiler - >>= loadAndApplyTemplate "templates/post.html" postCtx + >>= loadAndApplyTemplate "templates/post.html" postCtx >>= relativizeUrls create ["log/index.html"] $ do route idRoute compile $ do - posts <- recentFirst =<< loadAll "log/*.markdown" - let archiveCtx = - listField "posts" postForArchiveCtx (return posts) `mappend` - constField "title" "archive of log posts" `mappend` - defaultContext - makeItem "" - >>= loadAndApplyTemplate "templates/archive.html" archiveCtx + >>= loadAndApplyTemplate "templates/archive.html" postForArchiveCtx >>= loadAndApplyTemplate "templates/post.html" archiveCtx >>= relativizeUrls - match "index.html" $ do route idRoute compile $ do - posts <- recentFirst =<< loadAll "posts/*" - let indexCtx = - listField "posts" postCtx (return posts) `mappend` - constField "title" "Home" `mappend` - defaultContext - - getResourceBody - >>= applyAsTemplate indexCtx - >>= loadAndApplyTemplate "templates/default.html" indexCtx - >>= relativizeUrls + getResourceBody + >>= applyAsTemplate indexCtx + >>= loadAndApplyTemplate "templates/default.html" indexCtx + >>= relativizeUrls match "templates/*" $ compile templateBodyCompiler -------------------------------------------------------------------------------- +posts :: Compiler [Item String] +posts = recentFirst =<< loadAll "log/*.org" + +indexCtx :: Context String +indexCtx = + listField "posts" postCtx posts <> + constField "title" "Home" <> + defaultContext + +archiveCtx :: Context String +archiveCtx = + constField "title" "archive of log posts" <> + defaultContext + postCtx :: Context String postCtx = - dateField "date" "%B %e, %Y" `mappend` - defaultContext + dateField "date" "%B %e, %Y" <> defaultContext postForArchiveCtx :: Context String postForArchiveCtx = - dateField "date" "%d %b %Y" `mappend` + listField "posts" dateForArchiveCtx posts <> defaultContext + +dateForArchiveCtx :: Context String +dateForArchiveCtx = + dateField "date" "%d %b %Y" <> defaultContext |
