summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Frumin <difrumin@gmail.com>2014-01-11 23:42:34 +0400
committerDaniil Frumin <difrumin@gmail.com>2014-01-11 23:42:34 +0400
commitcacac208ef626f864b8ea563b221fdd5e6ba5b9b (patch)
treeb9acde20ffad84f6704e319038ac869c5aeb074f
parent8321a2a259f9022438389257b3a9286737236b03 (diff)
downloadhakyll-cacac208ef626f864b8ea563b221fdd5e6ba5b9b.tar.gz
Added documentation for 'Context' and 'defaultField'
-rw-r--r--src/Hakyll/Web/Template/Context.hs25
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`