@@ -124,11 +124,10 @@ readPageFromFile path = do
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
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)]
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.