aboutsummaryrefslogtreecommitdiff
path: root/hakyll/Main.hs
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-01-24 13:15:34 -0300
committerEuAndreh <eu@euandre.org>2020-01-24 13:15:34 -0300
commit1a08821a024cd09b361937b32d0498f21583d7e5 (patch)
tree86b9f08144fcf4e763f2e816919c9421aff360bd /hakyll/Main.hs
parentutils.nix: Revert change (diff)
downloadeuandre.org-1a08821a024cd09b361937b32d0498f21583d7e5.tar.gz
euandre.org-1a08821a024cd09b361937b32d0498f21583d7e5.tar.xz
Add pastebins.html listing page
Diffstat (limited to 'hakyll/Main.hs')
-rw-r--r--hakyll/Main.hs27
1 files changed, 24 insertions, 3 deletions
diff --git a/hakyll/Main.hs b/hakyll/Main.hs
index 6d27c66..139b607 100644
--- a/hakyll/Main.hs
+++ b/hakyll/Main.hs
@@ -20,13 +20,18 @@ main = hakyll $ do
match "fonts/*" $ do
route idRoute
compile copyFileCompiler
- match "pastebin/*.html" $ do
- route idRoute
- compile copyFileCompiler
match "root/*" $ do
route $ dropPrefix "root/"
compile copyFileCompiler
+ match "pastebin/*" $ do
+ route $ setExtension "html"
+ compile $ pandocCompiler
+ >>= loadAndApplyTemplate "templates/pastebin.html" pastebinCtx
+ >>= saveSnapshot "content"
+ >>= loadAndApplyTemplate "templates/default.html" pastebinCtx
+ >>= relativizeUrls
+
match "posts/*" $ do
route $ setExtension "html"
`composeRoutes` dropPrefix "posts/"
@@ -44,6 +49,19 @@ main = hakyll $ do
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
+ match "pastebins.html" $ do
+ route idRoute
+ compile $ do
+ pastebins <- recentFirst =<< loadAll "pastebin/*"
+ let pastebinCtx =
+ listField "pastebins" pastebinCtx (return pastebins) `mappend`
+ defaultContext
+
+ getResourceBody
+ >>= applyAsTemplate pastebinCtx
+ >>= loadAndApplyTemplate "templates/default.html" pastebinCtx
+ >>= relativizeUrls
+
match "index.html" $ do
route idRoute
compile $ do
@@ -96,6 +114,9 @@ postCtx =
dateField "date" "%B %e, %Y" `mappend`
defaultContext
+pastebinCtx :: Context String
+pastebinCtx = postCtx
+
feedCtx :: Context String
feedCtx =
bodyField "description" `mappend`