@@ -8,7 +8,6 @@ module Hakyll.Web.Template.Context
88 , listField
99
1010 , defaultContext
11− , teaserContext
1211 , bodyField
1312 , metadataField
1413 , urlField
@@ -19,6 +18,7 @@ module Hakyll.Web.Template.Context
1918 , getItemUTC
2019 , modificationTimeField
2120 , modificationTimeFieldWith
21+ , teaserField
2222 , missingField
2323 ) where
2424
@@ -96,16 +96,6 @@ defaultContext =
9696 missingField
9797
9898
99−--------------------------------------------------------------------------------
100−-- | A context with "teaser" key which contain a teaser of the item.
101−-- The item is loaded from the given snapshot (which should be saved
102−-- in the user code before any templates are applied).
103−teaserContext :: Snapshot -> Context String
104−teaserContext snapshot = field "teaser" $ \item ->
105− (needlePrefix teaserSeparator . itemBody) <$>
106− loadSnapshot (itemIdentifier item) snapshot
107−
108−
10999--------------------------------------------------------------------------------
110100teaserSeparator :: String
111101teaserSeparator = "<!--more-->"
@@ -245,6 +235,18 @@ modificationTimeFieldWith locale key fmt = field key $ \i -> do
245235 return $ formatTime locale fmt mtime
246236
247237
238+--------------------------------------------------------------------------------
239+-- | A context with "teaser" key which contain a teaser of the item.
240+-- The item is loaded from the given snapshot (which should be saved
241+-- in the user code before any templates are applied).
242+teaserField :: String -- ^ Key to use
243+ -> Snapshot -- ^ Snapshot to load
244+ -> Context String -- ^ Resulting context
245+teaserField key snapshot = field key $ \item ->
246+ (needlePrefix teaserSeparator . itemBody) <$>
247+ loadSnapshot (itemIdentifier item) snapshot
248+
249+
248250--------------------------------------------------------------------------------
249251missingField :: Context a
250252missingField = Context $ \k i -> fail $