From 2651627189ba8b35949580b9a31cc1dde4911f88 Mon Sep 17 00:00:00 2001 From: "Ivan N. Veselov" Date: Sat, 4 May 2013 17:24:03 +0300 Subject: Added "teasers" support to be used in posts index. Just add "" to separate the teaser and the rest of the article and use "$teaser$" key in the template! Closes issue #35. --- src/Hakyll/Web/Template/Context.hs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/Hakyll/Web') diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs index 2b85b30..7751423 100644 --- a/src/Hakyll/Web/Template/Context.hs +++ b/src/Hakyll/Web/Template/Context.hs @@ -7,6 +7,7 @@ module Hakyll.Web.Template.Context , functionField , defaultContext + , teaserContext , bodyField , metadataField , urlField @@ -40,7 +41,7 @@ import Hakyll.Core.Identifier import Hakyll.Core.Item import Hakyll.Core.Metadata import Hakyll.Core.Provider -import Hakyll.Core.Util.String (splitAll) +import Hakyll.Core.Util.String (splitAll, needlePrefix) import Hakyll.Web.Html @@ -90,6 +91,17 @@ defaultContext = titleField "title" `mappend` missingField +-------------------------------------------------------------------------------- +teaserContext :: Snapshot -> Context String +teaserContext snapshot = field "teaser" $ \item -> + (needlePrefix teaserSeparator . itemBody) <$> + loadSnapshot (itemIdentifier item) snapshot + + +-------------------------------------------------------------------------------- +teaserSeparator :: String +teaserSeparator = "" + -------------------------------------------------------------------------------- bodyField :: String -> Context String -- cgit v1.2.3