@@ -0,0 +1,31 @@
1+-- | A page is an important concept in Hakyll: it has a body (usually of the
2+-- type 'String') and number of metadata fields. This type is used to represent
3+-- pages on your website.
4+--
5+module Hakyll.Web.Page
6+ ( Page (..)
7+ , toMap
8+ ) where
9+
10+import Data.Map (Map)
11+import qualified Data.Map as M
12+
13+import Hakyll.Core.Writable
14+
15+-- | Type used to represent pages
16+--
17+data Page a = Page
18+ { pageMetadata :: Map String String
19+ , pageBody :: a
20+ }
21+
22+instance Functor Page where
23+ fmap f (Page m b) = Page m (f b)
24+
25+instance Writable a => Writable (Page a) where
26+ write p (Page _ b) = write p b
27+
28+-- | Convert a page to a map. The body will be placed in the @body@ key.
29+--
30+toMap :: Page String -> Map String String
31+toMap (Page m b) = M.insert "body" b m