summaryrefslogtreecommitdiff
path: root/src/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-03-29 18:19:19 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-03-29 18:19:19 +0200
commit379cd0eed48848ddf67c3de4def4f807372e713c (patch)
treea231b3b81609602b25250f2b16df76834705fa5a /src/Hakyll
parent8bd45b97dec932cf3814c68913693f2aefaac18f (diff)
downloadhakyll-379cd0eed48848ddf67c3de4def4f807372e713c.tar.gz
Add copyBodyToField, copyBodyFromField methods
Diffstat (limited to 'src/Hakyll')
-rw-r--r--src/Hakyll/Web/Page/Metadata.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Hakyll/Web/Page/Metadata.hs b/src/Hakyll/Web/Page/Metadata.hs
index b0545f3..79c616e 100644
--- a/src/Hakyll/Web/Page/Metadata.hs
+++ b/src/Hakyll/Web/Page/Metadata.hs
@@ -11,6 +11,8 @@ module Hakyll.Web.Page.Metadata
, copyField
, renderDateField
, renderDateFieldWith
+ , copyBodyToField
+ , copyBodyFromField
) where
import Prelude hiding (id)
@@ -138,3 +140,17 @@ renderDateFieldWith locale key format defaultValue =
"%Y-%m-%d"
dateString :: Maybe UTCTime
return $ formatTime locale format time
+
+-- | Copy the body of a page to a metadata field
+--
+copyBodyToField :: String -- ^ Destination key
+ -> Page String -- ^ Target page
+ -> Page String -- ^ Resulting page
+copyBodyToField key page = setField key (pageBody page) page
+
+-- | Copy a metadata field to the page body
+--
+copyBodyFromField :: String -- ^ Source key
+ -> Page String -- ^ Target page
+ -> Page String -- ^ Resulting page
+copyBodyFromField key page = fmap (const $ getField key page) page