summaryrefslogtreecommitdiffstats
path: root/site.hs
diff options
context:
space:
mode:
Diffstat (limited to 'site.hs')
-rw-r--r--site.hs67
1 files changed, 67 insertions, 0 deletions
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"
+ }