summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-06-15 00:35:06 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-06-15 00:35:06 +0200
commit7c75227b9a1e99bd01c605408d7c0cf5e175c978 (patch)
treef4fb5b6167a80fce6b495eb36ee940784934836b /src
parentefab53729d95cc69a8205bb691db9c12e9e06096 (diff)
downloadhakyll-7c75227b9a1e99bd01c605408d7c0cf5e175c978.tar.gz
Add pageCompilerWithFields
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Web/Page.hs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/Hakyll/Web/Page.hs b/src/Hakyll/Web/Page.hs
index 7520215..b7cf6fb 100644
--- a/src/Hakyll/Web/Page.hs
+++ b/src/Hakyll/Web/Page.hs
@@ -58,6 +58,7 @@ module Hakyll.Web.Page
, pageCompiler
, pageCompilerWith
, pageCompilerWithPandoc
+ , pageCompilerWithFields
, addDefaultFields
) where
@@ -108,10 +109,24 @@ pageCompilerWith state options = pageCompilerWithPandoc state options id
pageCompilerWithPandoc :: ParserState -> WriterOptions
-> (Pandoc -> Pandoc)
-> Compiler Resource (Page String)
-pageCompilerWithPandoc state options f = cached "pageCompilerWithPandoc" $
- readPageCompiler >>> addDefaultFields >>> arr applySelf
+pageCompilerWithPandoc state options f =
+ pageCompilerWithFields state options f id
+
+-- | This is another, even more advanced version of 'pageCompilerWithPandoc'.
+-- This function allows you to provide an arrow which is applied before the
+-- fields in a page are rendered. This means you can use this extra customizable
+-- stage to add custom fields which are inserted in the page.
+--
+pageCompilerWithFields :: ParserState -> WriterOptions
+ -> (Pandoc -> Pandoc)
+ -> Compiler (Page String) (Page String)
+ -> Compiler Resource (Page String)
+pageCompilerWithFields state options f g = cached cacheName $
+ readPageCompiler >>> addDefaultFields >>> g >>> arr applySelf
>>> pageReadPandocWith state
>>> arr (fmap (writePandocWith options . f))
+ where
+ cacheName = "Hakyll.Web.Page.pageCompilerWithFields"
-- | Add a number of default metadata fields to a page. These fields include:
--