diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2014-01-11 15:30:50 -0800 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2014-01-11 15:30:50 -0800 |
commit | ab776799ba95576e38bb9b16e3c432c42fbc1117 (patch) | |
tree | 290a50fb3c93c9cf6b497742b281ae3821ddbc24 /src/Hakyll/Web/Template/Context.hs | |
parent | 38ac6c218ffedd6bcdc95c220a18b95722807924 (diff) | |
parent | cacac208ef626f864b8ea563b221fdd5e6ba5b9b (diff) | |
download | hakyll-ab776799ba95576e38bb9b16e3c432c42fbc1117.tar.gz |
Merge pull request #206 from co-dan/docpatches
Added documentation for 'Context' and 'defaultField'
Diffstat (limited to 'src/Hakyll/Web/Template/Context.hs')
-rw-r--r-- | src/Hakyll/Web/Template/Context.hs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs index cd52eb0..80458ee 100644 --- a/src/Hakyll/Web/Template/Context.hs +++ b/src/Hakyll/Web/Template/Context.hs @@ -56,6 +56,20 @@ data ContextField -------------------------------------------------------------------------------- +-- | The 'Context' monoid. Please note that the order in which you +-- compose the items is important. For example in +-- +-- > field "A" f1 <> field "A" f2 +-- +-- the first context will overwrite the second. This is especially +-- important when something is being composed with +-- 'metadataField' (or 'defaultContext'). If you want your context to be +-- overwritten by the metadata fields, compose it from the right: +-- +-- @ +-- 'metadataField' \<\> field \"date\" fDate +-- @ +-- newtype Context a = Context { unContext :: String -> Item a -> Compiler ContextField } @@ -108,6 +122,17 @@ mapContext f (Context c) = Context $ \k i -> do -------------------------------------------------------------------------------- +-- | A context that contains (in that order) +-- +-- 1. A @$body$@ field +-- +-- 2. Metadata fields +-- +-- 3. A @$url$@ 'urlField' +-- +-- 4. A @$path$@ 'pathField' +-- +-- 5. A @$title$@ 'titleField' defaultContext :: Context String defaultContext = bodyField "body" `mappend` |