on master help sign in
Add pageCompilerWithFields
commit7c75227b9a1e99bd01c605408d7c0cf5e175c978 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateWed 15 Jun 2011, 00:35 (15 years ago) parentefab537
1 file changed+17−2
src/Hakyll/Web/Page.hs+17−2
src/Hakyll/Web/Page.hs+17−2
@@ -58,6 +58,7 @@ module Hakyll.Web.Page
5858 , pageCompiler
5959 , pageCompilerWith
6060 , pageCompilerWithPandoc
61+ , pageCompilerWithFields
6162 , addDefaultFields
6263 ) where
6364
@@ -108,10 +109,24 @@ pageCompilerWith state options = pageCompilerWithPandoc state options id
108109pageCompilerWithPandoc :: ParserState -> WriterOptions
109110 -> (Pandoc -> Pandoc)
110111 -> Compiler Resource (Page String)
111−pageCompilerWithPandoc state options f = cached "pageCompilerWithPandoc" $
112− readPageCompiler >>> addDefaultFields >>> arr applySelf
112+pageCompilerWithPandoc state options f =
113+ pageCompilerWithFields state options f id
114+
115+-- | This is another, even more advanced version of 'pageCompilerWithPandoc'.
116+-- This function allows you to provide an arrow which is applied before the
117+-- fields in a page are rendered. This means you can use this extra customizable
118+-- stage to add custom fields which are inserted in the page.
119+--
120+pageCompilerWithFields :: ParserState -> WriterOptions
121+ -> (Pandoc -> Pandoc)
122+ -> Compiler (Page String) (Page String)
123+ -> Compiler Resource (Page String)
124+pageCompilerWithFields state options f g = cached cacheName $
125+ readPageCompiler >>> addDefaultFields >>> g >>> arr applySelf
113126 >>> pageReadPandocWith state
114127 >>> arr (fmap (writePandocWith options . f))
128+ where
129+ cacheName = "Hakyll.Web.Page.pageCompilerWithFields"
115130
116131-- | Add a number of default metadata fields to a page. These fields include:
117132--