summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Core/Configuration.hs1
-rw-r--r--src/Hakyll/Web/Template/Context.hs24
2 files changed, 13 insertions, 12 deletions
diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs
index 790badc..a4bc90b 100644
--- a/src/Hakyll/Core/Configuration.hs
+++ b/src/Hakyll/Core/Configuration.hs
@@ -8,7 +8,6 @@ module Hakyll.Core.Configuration
--------------------------------------------------------------------------------
-import Control.Monad (void)
import Data.Default (Default (..))
import Data.List (isPrefixOf, isSuffixOf)
import System.Directory (canonicalizePath)
diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs
index 7b2d920..3fde93b 100644
--- a/src/Hakyll/Web/Template/Context.hs
+++ b/src/Hakyll/Web/Template/Context.hs
@@ -8,7 +8,6 @@ module Hakyll.Web.Template.Context
, listField
, defaultContext
- , teaserContext
, bodyField
, metadataField
, urlField
@@ -19,6 +18,7 @@ module Hakyll.Web.Template.Context
, getItemUTC
, modificationTimeField
, modificationTimeFieldWith
+ , teaserField
, missingField
) where
@@ -97,16 +97,6 @@ defaultContext =
--------------------------------------------------------------------------------
--- | A context with "teaser" key which contain a teaser of the item.
--- The item is loaded from the given snapshot (which should be saved
--- in the user code before any templates are applied).
-teaserContext :: Snapshot -> Context String
-teaserContext snapshot = field "teaser" $ \item ->
- (needlePrefix teaserSeparator . itemBody) <$>
- loadSnapshot (itemIdentifier item) snapshot
-
-
---------------------------------------------------------------------------------
teaserSeparator :: String
teaserSeparator = "<!--more-->"
@@ -246,6 +236,18 @@ modificationTimeFieldWith locale key fmt = field key $ \i -> do
--------------------------------------------------------------------------------
+-- | A context with "teaser" key which contain a teaser of the item.
+-- The item is loaded from the given snapshot (which should be saved
+-- in the user code before any templates are applied).
+teaserField :: String -- ^ Key to use
+ -> Snapshot -- ^ Snapshot to load
+ -> Context String -- ^ Resulting context
+teaserField key snapshot = field key $ \item ->
+ (needlePrefix teaserSeparator . itemBody) <$>
+ loadSnapshot (itemIdentifier item) snapshot
+
+
+--------------------------------------------------------------------------------
missingField :: Context a
missingField = Context $ \k i -> fail $
"Missing field $" ++ k ++ "$ in context for item " ++