summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Hakyll/Web/Template/Context.hs25
-rw-r--r--web/examples.markdown2
2 files changed, 27 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`
diff --git a/web/examples.markdown b/web/examples.markdown
index b53e138..28c512e 100644
--- a/web/examples.markdown
+++ b/web/examples.markdown
@@ -73,6 +73,8 @@ this list. This list has no particular ordering.
[source](https://github.com/Abizern/hblog)
- <http://freizl.github.io>,
[source](https://github.com/freizl/freizl.github.com/tree/master/build)
+- <http://covariant.me>,
+ [source](http://hub.darcs.net/co-dan/website)
## Hakyll 3.X