From 0a5e19c00453ee34c45f75ba54ec3b3f58a159cf Mon Sep 17 00:00:00 2001 From: Chris Hodapp Date: Fri, 1 Nov 2019 17:19:21 -0400 Subject: [PATCH] Progressed with CSS layout (I guess) --- site.hs | 39 ++++++++++++++++++++++++++++----------- templates/post-grid.html | 6 ++++-- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/site.hs b/site.hs index 581e4b0..3d6ddec 100644 --- a/site.hs +++ b/site.hs @@ -40,11 +40,23 @@ pandocMathCompiler = } in pandocCompilerWith defaultHakyllReaderOptions writerOptions +config :: Configuration +config = defaultConfiguration + +options :: Options +options = Options { verbosity = True + , optCommand = Watch { host = "0.0.0.0" + , port = 8000 + , no_server = False + } + } + -- | Main entry point for generating all code via Hakyll main :: IO () main = do E.setLocaleEncoding E.utf8 hakyll $ do + --hakyllWithArgs config options $ do -- Build up tags tags <- buildTags "posts/*" (fromCapture "tags/*.html") let postCtxTags = postCtxWithTags tags @@ -89,13 +101,6 @@ main = do >>= loadAndApplyTemplate "templates/default.html" postCtxTags >>= relativizeUrls - match "works/*" $ do - route $ setExtension "html" - compile $ pandocMathCompiler - >>= loadAndApplyTemplate "templates/post.html" postCtxTags - >>= loadAndApplyTemplate "templates/default.html" postCtxTags - >>= relativizeUrls - create ["archive.html"] $ do route idRoute compile $ do @@ -127,11 +132,19 @@ main = do >>= loadAndApplyTemplate "templates/default.html" indexCtx >>= relativizeUrls + match "works/*" $ do + route $ setExtension "html" + compile $ pandocMathCompiler + >>= saveSnapshot "content" + >>= loadAndApplyTemplate "templates/post.html" postCtxTags + >>= loadAndApplyTemplate "templates/default.html" postCtxTags + >>= relativizeUrls + create ["works.html"] $ do route idRoute compile $ do - posts <- loadAll "works/*" - let archiveCtx = + posts <- recentFirst =<< loadAllSnapshots "works/*" "content" + let archiveCtx = listField "works" postCtxTags (return posts) `mappend` constField "title" "Something" `mappend` defaultContext @@ -139,8 +152,12 @@ main = do >>= loadAndApplyTemplate "templates/works.html" archiveCtx >>= loadAndApplyTemplate "templates/default.html" archiveCtx >>= relativizeUrls - -- so it seems I have to have a match pattern on - -- works/* for the above to actually work? + + -- tried to follow + -- https://jaspervdj.be/hakyll/tutorials/05-snapshots-feeds.html + -- but I am stuck at this if I clean first & then watch: + -- [ERROR] Missing field $description$ in context for item works/2019-10-27-test.md + -- For some reason, bodyField just doesn't seem to add the context. match "templates/*" $ compile templateCompiler diff --git a/templates/post-grid.html b/templates/post-grid.html index daf90d9..0738b33 100644 --- a/templates/post-grid.html +++ b/templates/post-grid.html @@ -1,10 +1,12 @@
$for(works)$ -
+
+

$title$

- $title$ - $date$ + $date$ + $body$
$endfor$