diff options
| author | Carlos Sosa <gnusosa@gnusosa.net> | 2019-08-24 20:47:26 -0700 |
|---|---|---|
| committer | Carlos Sosa <gnusosa@gnusosa.net> | 2019-08-24 20:47:26 -0700 |
| commit | ec3a4a4715700294206d6e78d8b38a57a7de7592 (patch) | |
| tree | 82f7bf9cd081332216efb7f4e2eed77240f2c845 /src/site.hs | |
| parent | 03a8fc8f75a1bf0f5afb7d0dd11cd7e881a7d763 (diff) | |
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]]
Diffstat (limited to 'src/site.hs')
| -rw-r--r-- | src/site.hs | 67 |
1 files changed, 67 insertions, 0 deletions
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 |
