@@ -23,6 +23,7 @@ module Hakyll.Web.Template.Context
23 , modificationTimeField
23 , modificationTimeField
24 , modificationTimeFieldWith
24 , modificationTimeFieldWith
25 , teaserField
25 , teaserField
26+ , teaserFieldWithSeperator
26 , missingField
27 , missingField
@@ -318,9 +319,18 @@ modificationTimeFieldWith locale key fmt = field key $ \i -> do
318teaserField :: String -- ^ Key to use
319teaserField :: String -- ^ Key to use
319 -> Snapshot -- ^ Snapshot to load
320 -> Snapshot -- ^ Snapshot to load
320 -> Context String -- ^ Resulting context
321 -> Context String -- ^ Resulting context
322+teaserField = teaserFieldWithSeperator teaserSeparator
324+-- | A context with "teaser" key which contain a teaser of the item, defined as the snapshot content before the teaser separator.
325+-- The item is loaded from the given snapshot (which should be saved
326+-- in the user code before any templates are applied).
327+teaserFieldWithSeperator :: String -- ^ Separator to use
328+ -> String -- ^ Key to use
329+ -> Snapshot -- ^ Snapshot to load
330+ -> Context String -- ^ Resulting context
321−teaserField key snapshot = field key $ \item -> do
331+teaserFieldWithSeperator separator key snapshot = field key $ \item -> do
322 body <- itemBody <$> loadSnapshot (itemIdentifier item) snapshot
332 body <- itemBody <$> loadSnapshot (itemIdentifier item) snapshot
323− case needlePrefix teaserSeparator body of
333+ case needlePrefix separator body of
324 Nothing -> fail $
334 Nothing -> fail $
325 "Hakyll.Web.Template.Context: no teaser defined for " ++
335 "Hakyll.Web.Template.Context: no teaser defined for " ++
326 show (itemIdentifier item)
336 show (itemIdentifier item)