on master help sign in
Categories are more or less stable now.
0d2cfb0Jasper Van der Jeugt
src/Text/Hakyll.hs−1
@@ -19,7 +19,6 @@ defaultHakyllConfiguration = HakyllConfiguration
19 { additionalContext = M.empty
19 { additionalContext = M.empty
20 , siteDirectory = "_site"
20 , siteDirectory = "_site"
21 , cacheDirectory = "_cache"
21 , cacheDirectory = "_cache"
22− , enableCategories = False
23 }
22 }
24
23
25-- | Hakyll with a default configuration.
24-- | Hakyll with a default configuration.
src/Text/Hakyll/Hakyll.hs−2
@@ -19,8 +19,6 @@ data HakyllConfiguration = HakyllConfiguration
19 siteDirectory :: FilePath
19 siteDirectory :: FilePath
20 , -- | Directory for cache files.
20 , -- | Directory for cache files.
21 cacheDirectory :: FilePath
21 cacheDirectory :: FilePath
22− -- | Use categories in addition to tags.
23− , enableCategories :: Bool
24 }
22 }
25
23
26-- | Our custom monad stack.
24-- | Our custom monad stack.
src/Text/Hakyll/Page.hs+3−3
@@ -124,11 +124,10 @@ readPageFromFile path = do
124
124
125 -- Read file.
125 -- Read file.
126 contents <- liftIO $ readFile path
126 contents <- liftIO $ readFile path
127− enableCategories' <- askHakyll enableCategories
128 let sections = splitAtDelimiters $ lines contents
127 let sections = splitAtDelimiters $ lines contents
129 context = concat $ zipWith ($) sectionFunctions sections
128 context = concat $ zipWith ($) sectionFunctions sections
130 page = fromContext $ M.fromList $
129 page = fromContext $ M.fromList $
131− [ ("category", getCategory path) | enableCategories' ] ++
130+ category ++
132 [ ("url", url)
131 [ ("url", url)
133 , ("path", path)
132 , ("path", path)
134 ] ++ context
133 ] ++ context
@@ -136,7 +135,8 @@ readPageFromFile path = do
136 return page
135 return page
137 where
136 where
138 url = toURL path
137 url = toURL path
139− getCategory = last . splitDirectories . takeDirectory
138+ category = let dirs = splitDirectories $ takeDirectory path
139+ in [("category", last dirs) | not (null dirs)]
140
140
141-- | Read a page. Might fetch it from the cache if available. Otherwise, it will
141-- | Read a page. Might fetch it from the cache if available. Otherwise, it will
142-- read it from the file given and store it in the cache.
142-- read it from the file given and store it in the cache.