hakyll/src/Hakyll/Web/Page.hs

30 lines
750 B
Haskell
Raw Normal View History

2010-12-26 18:03:03 +00:00
-- | 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.
--
2010-12-28 10:12:45 +00:00
{-# LANGUAGE DeriveDataTypeable #-}
2010-12-26 18:03:03 +00:00
module Hakyll.Web.Page
( Page (..)
, toMap
2010-12-30 20:18:55 +00:00
, pageRead
2010-12-26 18:03:03 +00:00
) where
2010-12-30 20:18:55 +00:00
import Control.Arrow ((>>^))
2010-12-27 17:46:23 +00:00
2010-12-26 18:03:03 +00:00
import Data.Map (Map)
import qualified Data.Map as M
2010-12-30 20:18:55 +00:00
import Hakyll.Core.Compiler
import Hakyll.Web.Page.Internal
import Hakyll.Web.Page.Read
2010-12-26 18:03:03 +00:00
-- | 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
2010-12-30 20:18:55 +00:00
-- | Read a page (do not render it)
--
pageRead :: Compiler a (Page String)
pageRead = getResourceString >>^ readPage