@@ -1,6 +1,7 @@
11module Text.Hakyll.Page
22 ( Page,
33 fromContext,
4+ getValue,
45 copyValueWith,
56 getBody,
67 readPage,
@@ -29,6 +30,11 @@ data Page = Page (M.Map B.ByteString B.ByteString)
2930fromContext :: (M.Map B.ByteString B.ByteString) -> Page
3031fromContext = Page
3132
33+-- | Obtain a value from a page. Will resturn an empty string when nothing is
34+-- found.
35+getValue :: String -> Page -> B.ByteString
36+getValue str (Page page) = fromMaybe B.empty $ M.lookup (B.pack str) page
37+
3238-- | Do something with a value of the page.
3339copyValueWith :: String -- ^ Key of which the value should be copied.
3440 -> String -- ^ Key the value should be copied to.