@@ -2,7 +2,8 @@ module Text.Hakyll.Page
22 ( Page,
33 fromContext,
44 getBody,
5− readPage
5+ readPage,
6+ writePage
67 ) where
78
89import qualified Data.Map as M
@@ -116,6 +117,13 @@ readPage pagePath = do
116117 where url = toURL pagePath
117118 cacheFile = toCache url
118119
120+-- | Write a page to the site destination.
121+writePage :: Page -> IO ()
122+writePage page = do
123+ let destination = toDestination $ getURL page
124+ makeDirectories destination
125+ B.writeFile destination (getBody page)
126+
119127-- Make pages renderable.
120128instance Renderable Page where
121129 getDependencies = (:[]) . flip addExtension ".html" . dropExtension . getPageURL