on master help sign in
Categories are more or less stable now.
commit0d2cfb08a777f3a6459c14e40a52633cb1a2aa90 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateThu 28 Jan 2010, 13:00 (17 years ago) parenta600b84
3 files changed+3−6
src/Text/Hakyll.hs−1 src/Text/Hakyll/Hakyll.hs−2 src/Text/Hakyll/Page.hs+3−3
src/Text/Hakyll.hs−1
@@ -19,7 +19,6 @@ defaultHakyllConfiguration = HakyllConfiguration
1919 { additionalContext = M.empty
2020 , siteDirectory = "_site"
2121 , cacheDirectory = "_cache"
22− , enableCategories = False
2322 }
2423
2524-- | Hakyll with a default configuration.
src/Text/Hakyll/Hakyll.hs−2
@@ -19,8 +19,6 @@ data HakyllConfiguration = HakyllConfiguration
1919 siteDirectory :: FilePath
2020 , -- | Directory for cache files.
2121 cacheDirectory :: FilePath
22− -- | Use categories in addition to tags.
23− , enableCategories :: Bool
2422 }
2523
2624-- | Our custom monad stack.
src/Text/Hakyll/Page.hs+3−3
@@ -124,11 +124,10 @@ readPageFromFile path = do
124124
125125 -- Read file.
126126 contents <- liftIO $ readFile path
127− enableCategories' <- askHakyll enableCategories
128127 let sections = splitAtDelimiters $ lines contents
129128 context = concat $ zipWith ($) sectionFunctions sections
130129 page = fromContext $ M.fromList $
131− [ ("category", getCategory path) | enableCategories' ] ++
130+ category ++
132131 [ ("url", url)
133132 , ("path", path)
134133 ] ++ context
@@ -136,7 +135,8 @@ readPageFromFile path = do
136135 return page
137136 where
138137 url = toURL path
139− getCategory = last . splitDirectories . takeDirectory
138+ category = let dirs = splitDirectories $ takeDirectory path
139+ in [("category", last dirs) | not (null dirs)]
140140
141141-- | Read a page. Might fetch it from the cache if available. Otherwise, it will
142142-- read it from the file given and store it in the cache.