summaryrefslogtreecommitdiff
path: root/site.hs
diff options
context:
space:
mode:
authorCarlos Sosa <gnusosa@gnusosa.net>2019-08-14 23:38:25 -0700
committerCarlos Sosa <gnusosa@gnusosa.net>2019-08-14 23:38:25 -0700
commitb0098326cddad2437f9d4b2f30af6568acc5ca54 (patch)
treeee416e9126cd40a3e9f203dbc1866d8b86147dbc /site.hs
parentcbc9b06e4abe070de71529e02fcb9f247e56c85e (diff)
Move to Compilers/Context as functions
* Added a match for the articles category On =match "article/**"=, we create the routes via =idRoute=, and later only pass the HTML body of each entry to the compile step that also captures any metadata on the file. All of this on the =compile getResourceBody= function
Diffstat (limited to 'site.hs')
-rw-r--r--site.hs37
1 files changed, 23 insertions, 14 deletions
diff --git a/site.hs b/site.hs
index 1913d6f..3148518 100644
--- a/site.hs
+++ b/site.hs
@@ -15,12 +15,6 @@ main = hakyll $ do
route idRoute
compile compressCssCompiler
- match (fromList ["about.rst", "contact.markdown"]) $ do
- route $ setExtension "html"
- compile $ pandocCompiler
- >>= loadAndApplyTemplate "templates/default.html" defaultContext
- >>= relativizeUrls
-
match "log/*.org" $ do
route $ setExtension "html"
compile $ pandocCompiler
@@ -35,12 +29,15 @@ main = hakyll $ do
>>= loadAndApplyTemplate "templates/post.html" archiveCtx
>>= relativizeUrls
+ match "article/**" $ do
+ route idRoute
+ compile getResourceBody
+
match "index.html" $ do
route idRoute
compile $ do
getResourceBody
>>= applyAsTemplate indexCtx
- >>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
match "templates/*" $ compile templateBodyCompiler
@@ -50,16 +47,27 @@ main = hakyll $ do
posts :: Compiler [Item String]
posts = recentFirst =<< loadAll "log/*.org"
+articles :: Compiler [Item String]
+articles = loadAll "article/**"
+
+recentPosts :: Compiler [Item String]
+recentPosts = (take 4) <$> posts
+
+recentArticles :: Compiler [Item String]
+recentArticles = (take 4) <$> articles
+
indexCtx :: Context String
indexCtx =
- listField "posts" postCtx posts <>
- constField "title" "Home" <>
- defaultContext
+ listField "articles" defaultContext recentArticles
+ <> listField "rposts" defaultContext recentPosts
+ <> constField "essays" "Soon"
+ <> constField "title" "Home"
+ <> defaultContext
archiveCtx :: Context String
archiveCtx =
- constField "title" "archive of log posts" <>
- defaultContext
+ constField "title" "archive of log posts"
+ <> defaultContext
postCtx :: Context String
postCtx =
@@ -67,9 +75,10 @@ postCtx =
postForArchiveCtx :: Context String
postForArchiveCtx =
- listField "posts" dateForArchiveCtx posts <>
- defaultContext
+ listField "posts" dateForArchiveCtx posts
+ <> defaultContext
dateForArchiveCtx :: Context String
dateForArchiveCtx =
dateField "date" "%d %b %Y" <> defaultContext
+