@@ -1,5 +1,5 @@
1-- | A module for dealing with @Page@s. This module is mostly internally used.
1-- | A module for dealing with @Page@s. This module is mostly internally used.
2−module Text.Hakyll.Page
2+module Text.Hakyll.Internal.Page
4 , fromContext
4 , fromContext
@@ -25,6 +25,7 @@ import Text.Hakyll.File
25import Text.Hakyll.Util (trim)
25import Text.Hakyll.Util (trim)
26import Text.Hakyll.Context (Context)
26import Text.Hakyll.Context (Context)
27import Text.Hakyll.Renderable
27import Text.Hakyll.Renderable
28+import Text.Hakyll.RenderAction
28import Text.Hakyll.Regex (substituteRegex, matchesRegex)
29import Text.Hakyll.Regex (substituteRegex, matchesRegex)
30-- | A Page is basically key-value mapping. Certain keys have special
31-- | A Page is basically key-value mapping. Certain keys have special
@@ -125,7 +126,7 @@ readSection renderFunction isFirst ls
126-- | Read a page from a file. Metadata is supported, and if the filename
127-- | Read a page from a file. Metadata is supported, and if the filename
127-- has a @.markdown@ extension, it will be rendered using pandoc.
128-- has a @.markdown@ extension, it will be rendered using pandoc.
128−readPageFromFile :: FilePath -> Hakyll Page
129+readPageFromFile :: FilePath -> Hakyll Context
129readPageFromFile path = do
130readPageFromFile path = do
130 let renderFunction = getRenderFunction $ takeExtension path
131 let renderFunction = getRenderFunction $ takeExtension path
131 sectionFunctions = map (readSection renderFunction)
132 sectionFunctions = map (readSection renderFunction)
@@ -133,23 +134,18 @@ readPageFromFile path = do
134 -- Read file.
135 -- Read file.
135 contents <- liftIO $ readFile path
136 contents <- liftIO $ readFile path
137 let sections = splitAtDelimiters $ lines contents
137 let sections = splitAtDelimiters $ lines contents
138− context = concat $ zipWith ($) sectionFunctions sections
138+ sectionsData = concat $ zipWith ($) sectionFunctions sections
139− page = fromContext $ M.fromList $
139+ context = M.fromList $ category ++ sectionsData
145− return page
141+ return context
147 category = let dirs = splitDirectories $ takeDirectory path
143 category = let dirs = splitDirectories $ takeDirectory path
148 in [("category", last dirs) | not (null dirs)]
144 in [("category", last dirs) | not (null dirs)]
150-- | Read a page. Might fetch it from the cache if available. Otherwise, it will
146-- | Read a page. Might fetch it from the cache if available. Otherwise, it will
151-- read it from the file given and store it in the cache.
147-- read it from the file given and store it in the cache.
152−readPage :: FilePath -> Hakyll Page
148+readPage :: FilePath -> Hakyll Context
153readPage path = do
149readPage path = do
154 isCacheMoreRecent' <- isCacheMoreRecent fileName [path]
150 isCacheMoreRecent' <- isCacheMoreRecent fileName [path]
155 if isCacheMoreRecent' then getFromCache fileName
151 if isCacheMoreRecent' then getFromCache fileName