@@ -58,6 +58,7 @@ module Hakyll.Web.Page
58 , pageCompiler
58 , pageCompiler
59 , pageCompilerWith
59 , pageCompilerWith
60 , pageCompilerWithPandoc
60 , pageCompilerWithPandoc
61+ , pageCompilerWithFields
61 , addDefaultFields
62 , addDefaultFields
@@ -108,10 +109,24 @@ pageCompilerWith state options = pageCompilerWithPandoc state options id
108pageCompilerWithPandoc :: ParserState -> WriterOptions
109pageCompilerWithPandoc :: ParserState -> WriterOptions
109 -> (Pandoc -> Pandoc)
110 -> (Pandoc -> Pandoc)
110 -> Compiler Resource (Page String)
111 -> Compiler Resource (Page String)
111−pageCompilerWithPandoc state options f = cached "pageCompilerWithPandoc" $
112+pageCompilerWithPandoc state options f =
113+ pageCompilerWithFields state options f id
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.
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 $
112− readPageCompiler >>> addDefaultFields >>> arr applySelf
125+ readPageCompiler >>> addDefaultFields >>> g >>> arr applySelf
113 >>> pageReadPandocWith state
126 >>> pageReadPandocWith state
114 >>> arr (fmap (writePandocWith options . f))
127 >>> arr (fmap (writePandocWith options . f))
129+ cacheName = "Hakyll.Web.Page.pageCompilerWithFields"
116-- | Add a number of default metadata fields to a page. These fields include:
131-- | Add a number of default metadata fields to a page. These fields include: