diff options
author | 2024-05-07 05:21:25 +0100 | |
---|---|---|
committer | 2024-05-07 05:21:25 +0100 | |
commit | c56582cb9d4d58b22d10aa083280bdb64966b355 (patch) | |
tree | 7f4109ef01f2ff24133ff38a98daced324d07c83 /site.hs | |
download | bunblog-c56582cb9d4d58b22d10aa083280bdb64966b355.tar.gz bunblog-c56582cb9d4d58b22d10aa083280bdb64966b355.tar.bz2 bunblog-c56582cb9d4d58b22d10aa083280bdb64966b355.zip |
initial commit
Diffstat (limited to 'site.hs')
-rw-r--r-- | site.hs | 67 |
1 files changed, 67 insertions, 0 deletions
@@ -0,0 +1,67 @@ +-------------------------------------------------------------------------------- +{-# LANGUAGE OverloadedStrings #-} +import Data.Monoid (mappend) +import Hakyll + + +-------------------------------------------------------------------------------- +main :: IO () +main = hakyll $ do + create ["feed.xml"] $ do + route idRoute + compile $ do + let feedCtx = postCtx `mappend` bodyField "description" + posts <- fmap (take 10) . recentFirst =<< loadAllSnapshots "posts/*" "content" + renderAtom feedConfig feedCtx posts + + match "images/*" $ do + route idRoute + compile copyFileCompiler + + match "fonts/*" $ do + route idRoute + compile copyFileCompiler + + match "style.css" $ do + route idRoute + compile compressCssCompiler + + match "posts/*" $ do + route $ setExtension "html" + compile $ pandocCompiler + >>= loadAndApplyTemplate "templates/post.html" postCtx + >>= saveSnapshot "content" + >>= loadAndApplyTemplate "templates/default.html" postCtx + >>= relativizeUrls + + + match "index.html" $ do + route idRoute + compile $ do + posts <- recentFirst =<< loadAll "posts/*" + let indexCtx = + listField "posts" postCtx (return posts) `mappend` + defaultContext + + getResourceBody + >>= applyAsTemplate indexCtx + >>= loadAndApplyTemplate "templates/default.html" indexCtx + >>= relativizeUrls + + match "templates/*" $ compile templateBodyCompiler + + +-------------------------------------------------------------------------------- +postCtx :: Context String +postCtx = + dateField "date" "%Y-%m-%d" `mappend` + defaultContext + +feedConfig :: FeedConfiguration +feedConfig = FeedConfiguration + { feedTitle = "cel's dev?blog" + , feedDescription = "banished technology" + , feedAuthorName = "cel ❀" + , feedAuthorEmail = "cel@bunny.garden" + , feedRoot = "https://bunny.garden/~cel" + } |