From baacd0288136b41507479bc40c29f4f69e1f688a Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 7 May 2024 05:21:25 +0100 Subject: initial commit --- site.hs | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 site.hs (limited to 'site.hs') diff --git a/site.hs b/site.hs new file mode 100644 index 0000000..0313066 --- /dev/null +++ b/site.hs @@ -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" + } -- cgit