diff options
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Hakyll/Page.hs | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs index f106303..4bcacc4 100644 --- a/src/Text/Hakyll/Page.hs +++ b/src/Text/Hakyll/Page.hs @@ -1,10 +1,8 @@ module Text.Hakyll.Page ( Page, fromContext, - addContext, getBody, - readPage, - pageFromList + readPage ) where import qualified Data.Map as M @@ -28,10 +26,6 @@ data Page = Page (M.Map B.ByteString B.ByteString) fromContext :: (M.Map B.ByteString B.ByteString) -> Page fromContext = Page --- | Add a key-value mapping to the Page. -addContext :: String -> String -> Page -> Page -addContext key value (Page page) = Page $ M.insert (B.pack key) (B.pack value) page - -- | Auxiliary function to pack a pair. packPair :: (String, String) -> (B.ByteString, B.ByteString) packPair (a, b) = (B.pack a, B.pack b) @@ -113,7 +107,8 @@ readPage pagePath = do -- Render file let rendered = B.pack $ (renderFunction $ takeExtension path) body seq rendered $ hClose handle - let page = addContext "url" url $ Page $ M.fromList $ (B.pack "body", rendered) : map packPair context + let page = fromContext $ M.fromList $ + [(B.pack "body", rendered), packPair ("url", url)] ++ map packPair context -- Cache if needed if getFromCache then return () else cachePage page @@ -121,10 +116,6 @@ readPage pagePath = do where url = toURL pagePath cacheFile = toCache url --- | Create a key-value mapping page from an association list. -pageFromList :: [(String, String)] -> Page -pageFromList = Page . M.fromList . map packPair - -- Make pages renderable. instance Renderable Page where getDependencies = (:[]) . flip addExtension ".html" . dropExtension . getPageURL |