on master help sign in
Added support for a custom teaser separator

This way you don't need to use the <!--more--> separator. You can define your own.

commit8323f784b88d0c9a61e204da81412509b0baf0b9 authorTom Sydney Kerckhove <syd.kerckhove@student.kuleuven.be> dateMon 30 Mar 2015, 19:18 (12 years ago) parent46afe34
1 file changed+12−2
src/Hakyll/Web/Template/Context.hs+12−2
src/Hakyll/Web/Template/Context.hs+12−2
@@ -23,6 +23,7 @@ module Hakyll.Web.Template.Context
2323 , modificationTimeField
2424 , modificationTimeFieldWith
2525 , teaserField
26+ , teaserFieldWithSeperator
2627 , missingField
2728 ) where
2829
@@ -318,9 +319,18 @@ modificationTimeFieldWith locale key fmt = field key $ \i -> do
318319teaserField :: String -- ^ Key to use
319320 -> Snapshot -- ^ Snapshot to load
320321 -> Context String -- ^ Resulting context
321−teaserField key snapshot = field key $ \item -> do
322+teaserField = teaserFieldWithSeperator teaserSeparator
323+
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
331+teaserFieldWithSeperator separator key snapshot = field key $ \item -> do
322332 body <- itemBody <$> loadSnapshot (itemIdentifier item) snapshot
323− case needlePrefix teaserSeparator body of
333+ case needlePrefix separator body of
324334 Nothing -> fail $
325335 "Hakyll.Web.Template.Context: no teaser defined for " ++
326336 show (itemIdentifier item)