summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-26 19:03:03 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-26 19:03:03 +0100
commite6c758e6dc9709f67d62f42cfa1b1662ceb779ae (patch)
tree31d6394f375e23b66616e8234e5c9dffa12eedae /src
parentbc92f7fea561a3f9ae69fd499e817f9244fcb206 (diff)
downloadhakyll-e6c758e6dc9709f67d62f42cfa1b1662ceb779ae.tar.gz
Add Page module
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Web/Page.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Hakyll/Web/Page.hs b/src/Hakyll/Web/Page.hs
new file mode 100644
index 0000000..151364f
--- /dev/null
+++ b/src/Hakyll/Web/Page.hs
@@ -0,0 +1,31 @@
+-- | A page is an important concept in Hakyll: it has a body (usually of the
+-- type 'String') and number of metadata fields. This type is used to represent
+-- pages on your website.
+--
+module Hakyll.Web.Page
+ ( Page (..)
+ , toMap
+ ) where
+
+import Data.Map (Map)
+import qualified Data.Map as M
+
+import Hakyll.Core.Writable
+
+-- | Type used to represent pages
+--
+data Page a = Page
+ { pageMetadata :: Map String String
+ , pageBody :: a
+ }
+
+instance Functor Page where
+ fmap f (Page m b) = Page m (f b)
+
+instance Writable a => Writable (Page a) where
+ write p (Page _ b) = write p b
+
+-- | Convert a page to a map. The body will be placed in the @body@ key.
+--
+toMap :: Page String -> Map String String
+toMap (Page m b) = M.insert "body" b m