From ec3a4a4715700294206d6e78d8b38a57a7de7592 Mon Sep 17 00:00:00 2001 From: Carlos Sosa Date: Sat, 24 Aug 2019 20:47:26 -0700 Subject: Move to use src/ directory with the addition of Site modules - Added Content record with Lenses. - Added Rules based content compilers * This is all based on [[https://github.com/blaenk/blaenk.github.io/blob/source/src/Site/Compilers.hs]] --- src/site.hs | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/site.hs (limited to 'src/site.hs') diff --git a/src/site.hs b/src/site.hs new file mode 100644 index 0000000..be4af68 --- /dev/null +++ b/src/site.hs @@ -0,0 +1,67 @@ +{-# LANGUAGE OverloadedStrings #-} +import Data.Monoid ( (<>) ) +import Hakyll +import Control.Lens +import Site.Rules ( indexRules + , contentRules + ) +import Site.Contexts +import Site.Content + +main :: IO () +main = hakyll $ do + match "img/*" $ do + route idRoute + compile copyFileCompiler + + match "css/*" $ do + route idRoute + compile compressCssCompiler + + match "article/**" $ do + route idRoute + compile getResourceBody + + match "index.html" $ do + route idRoute + compile + $ getResourceBody + >>= applyAsTemplate indexCtx + >>= relativizeUrls + + match "templates/*" $ compile templateBodyCompiler + + let log = Content { _contentPattern = "log/*.org" + , _contentPaths = [] + , _contentRoute = setExtension "html" + , _contentTemplate = "post" + , _contentIndexTemplate = "post" + , _contentContext = postCtx + , _contentIndexContext = postCtx + } + + logIndex = Content + { _contentPaths = [fromFilePath "log/index.html"] + , _contentPattern = "" + , _contentRoute = idRoute + , _contentIndexTemplate = "post-list" + , _contentTemplate = "post" + , _contentContext = logArchiveCtx + , _contentIndexContext = postForArchiveCtx + } + + gsoc = log & contentPattern .~ "gsoc/*.org" + + gsocIndex = + logIndex + & contentPaths + .~ [fromFilePath "gsoc/index.html"] + & contentContext + .~ gsocArchiveCtx + & contentIndexContext + .~ gsocPostForArchiveCtx + + contentRules log + indexRules logIndex + contentRules gsoc + indexRules gsocIndex -- cgit v1.3-2-g0d8e