on master help sign in
Merged CustomPage and RenderableFilePath into one file.
333c19dJasper Van der Jeugt
hakyll.cabal+1−2
@@ -22,7 +22,6 @@ library
22 pandoc >= 1
22 pandoc >= 1
23 exposed-modules: Text.Hakyll.Render
23 exposed-modules: Text.Hakyll.Render
24 Text.Hakyll.Renderable
24 Text.Hakyll.Renderable
25+ Text.Hakyll.Renderables
25 Text.Hakyll.Page
26 Text.Hakyll.Page
26− Text.Hakyll.CustomPage
27− Text.Hakyll.RenderableFilePath
28 Text.Hakyll.Util
27 Text.Hakyll.Util
src/Text/Hakyll/RenderableFilePath.hsdeleted−16
@@ -1,16 +0,0 @@
1−module Text.Hakyll.RenderableFilePath
2− ( RenderableFilePath (..)
3− ) where
4−
5−import System.FilePath
6−import Text.Hakyll.Renderable
7−import Text.Hakyll.Util
8−import Text.Hakyll.Page
9−
10−newtype RenderableFilePath = RenderableFilePath FilePath
11−
12−-- We can render filepaths
13−instance Renderable RenderableFilePath where
14− getDependencies (RenderableFilePath path) = return path
15− getURL (RenderableFilePath path) = toURL path
16− toContext (RenderableFilePath path) = readPage path >>= toContext
src/Text/Hakyll/CustomPage.hs → src/Text/Hakyll/Renderables.hsrenamed+17−2
@@ -1,12 +1,16 @@
1−module Text.Hakyll.CustomPage
1+module Text.Hakyll.Renderables
2 ( CustomPage,
2 ( CustomPage,
3− createCustomPage
3+ createCustomPage,
4+ PagePath,
5+ createPagePath
4 ) where
6 ) where
5
7
6import System.FilePath
8import System.FilePath
7import qualified Data.ByteString.Lazy.Char8 as B
9import qualified Data.ByteString.Lazy.Char8 as B
8import qualified Data.Map as M
10import qualified Data.Map as M
9import Control.Monad
11import Control.Monad
12+import Text.Hakyll.Util
13+import Text.Hakyll.Page
10import Text.Hakyll.Renderable
14import Text.Hakyll.Renderable
11
15
12data CustomPage = CustomPage { url :: String,
16data CustomPage = CustomPage { url :: String,
@@ -27,3 +31,14 @@ instance Renderable CustomPage where
27 values <- mapM (either (return . B.pack) (>>= return) . snd) (mapping page)
31 values <- mapM (either (return . B.pack) (>>= return) . snd) (mapping page)
28 let keys = map (B.pack . fst) (mapping page)
32 let keys = map (B.pack . fst) (mapping page)
29 return $ M.fromList $ (B.pack "url", B.pack $ url page) : zip keys values
33 return $ M.fromList $ (B.pack "url", B.pack $ url page) : zip keys values
34+
35+data PagePath = PagePath FilePath
36+
37+createPagePath :: FilePath -> PagePath
38+createPagePath = PagePath
39+
40+-- We can render filepaths
41+instance Renderable PagePath where
42+ getDependencies (PagePath path) = return path
43+ getURL (PagePath path) = toURL path
44+ toContext (PagePath path) = readPage path >>= toContext