From 7c75227b9a1e99bd01c605408d7c0cf5e175c978 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 15 Jun 2011 00:35:06 +0200 Subject: Add pageCompilerWithFields --- src/Hakyll/Web/Page.hs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/Hakyll/Web') 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: -- -- cgit v1.2.3