hakyll 4.4.3.0 → 4.4.3.1
raw patch · 2 files changed
+36/−5 lines, 2 filesdep ~text
Dependency ranges changed: text
Files
- hakyll.cabal +3/−3
- src/Hakyll/Web/Template/Context.hs +33/−2
hakyll.cabal view
@@ -1,5 +1,5 @@ Name: hakyll-Version: 4.4.3.0+Version: 4.4.3.1 Synopsis: A static website compiler library Description:@@ -166,7 +166,7 @@ regex-base >= 0.93 && < 0.94, regex-tdfa >= 1.1 && < 1.2, tagsoup >= 0.12.6 && < 0.14,- text >= 0.11 && < 1.1,+ text >= 0.11 && < 1.2, time >= 1.1 && < 1.5 If flag(previewServer)@@ -252,7 +252,7 @@ regex-base >= 0.93 && < 0.94, regex-tdfa >= 1.1 && < 1.2, tagsoup >= 0.12.6 && < 0.14,- text >= 0.11 && < 1.1,+ text >= 0.11 && < 1.2, time >= 1.1 && < 1.5 If flag(previewServer)
src/Hakyll/Web/Template/Context.hs view
@@ -56,6 +56,20 @@ --------------------------------------------------------------------------------+-- | 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 }@@ -73,11 +87,16 @@ ---------------------------------------------------------------------------------field :: String -> (Item a -> Compiler String) -> Context a+-- | Constructs a new field in the 'Context.'+field :: String -- ^ Key+ -> (Item a -> Compiler String) -- ^ Function that constructs a + -- value based on the item+ -> Context a field key value = field' key (fmap StringField . value) --------------------------------------------------------------------------------+-- | Creates a 'field' that does not depend on the 'Item' constField :: String -> String -> Context a constField key = field key . const . return @@ -108,6 +127,17 @@ --------------------------------------------------------------------------------+-- | 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`@@ -124,6 +154,7 @@ --------------------------------------------------------------------------------+-- | Constructs a 'field' that contains the body of the item. bodyField :: String -> Context String bodyField key = field key $ return . itemBody @@ -150,7 +181,7 @@ ----------------------------------------------------------------------------------- | This title field takes the basename of the underlying file by default+-- | This title 'field' takes the basename of the underlying file by default titleField :: String -> Context a titleField = mapContext takeBaseName . pathField