diff options
| author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2013-05-04 07:40:26 -0700 |
|---|---|---|
| committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2013-05-04 07:40:26 -0700 |
| commit | e5709c0c736ced70d500ff8306c0e1fea9eeef59 (patch) | |
| tree | 333ed9213269703c2473ab92f4e76606f19a685e /src/Hakyll/Web | |
| parent | ca80171caf1328bc869c61d2f51b1fd657779532 (diff) | |
| parent | 2651627189ba8b35949580b9a31cc1dde4911f88 (diff) | |
| download | hakyll-e5709c0c736ced70d500ff8306c0e1fea9eeef59.tar.gz | |
Merge pull request #143 from sphynx/master
Added teasers support
Diffstat (limited to 'src/Hakyll/Web')
| -rw-r--r-- | src/Hakyll/Web/Template/Context.hs | 14 |
1 files changed, 13 insertions, 1 deletions
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 = "<!-- teaser_end -->" + -------------------------------------------------------------------------------- bodyField :: String -> Context String |
