@@ -1,6 +1,7 @@
1module Text.Hakyll.Page
1module Text.Hakyll.Page
3 fromContext,
3 fromContext,
@@ -28,6 +29,17 @@ data Page = Page (M.Map B.ByteString B.ByteString)
28fromContext :: (M.Map B.ByteString B.ByteString) -> Page
29fromContext :: (M.Map B.ByteString B.ByteString) -> Page
29fromContext = Page
30fromContext = Page
32+-- | Do something with a value of the page.
33+copyValueWith :: String -- ^ Key of which the value should be copied.
34+ -> String -- ^ Key the value should be copied to.
35+ -> (B.ByteString -> B.ByteString) -- ^ Function to apply on the value.
36+ -> Page -- ^ Page on which to apply this modification.
38+copyValueWith src dst f p@(Page page) = case M.lookup (B.pack src) page of
40+ (Just value) -> Page $ M.insert (B.pack dst) (f value) page
31-- | Auxiliary function to pack a pair.
43-- | Auxiliary function to pack a pair.
32packPair :: (String, String) -> (B.ByteString, B.ByteString)
44packPair :: (String, String) -> (B.ByteString, B.ByteString)
33packPair (a, b) = (B.pack a, B.pack b)
45packPair (a, b) = (B.pack a, B.pack b)