on master help sign in
Add default title
commit1b5a0220f99742586e8c2c498f8ad878cddd30dd authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSun 14 Nov 2010, 22:48 (16 years ago) parent50459dc
2 files changed+6−15
src/Text/Hakyll/ContextManipulations.hs+3−15 src/Text/Hakyll/Page.hs+3
src/Text/Hakyll/ContextManipulations.hs+3−15
@@ -2,7 +2,6 @@
22-- manipulate @Context@s.
33module Text.Hakyll.ContextManipulations
44 ( renderValue
5− , renderMissingValue
65 , changeValue
76 , changeUrl
87 , copyValue
@@ -14,7 +13,7 @@ module Text.Hakyll.ContextManipulations
1413 ) where
1514
1615import Control.Monad (liftM)
17−import Control.Arrow (arr, (>>>))
16+import Control.Arrow (arr)
1817import System.Locale (TimeLocale, defaultTimeLocale)
1918import System.FilePath (takeFileName, addExtension, dropExtension)
2019import Data.Time.Format (parseTime, formatTime)
@@ -33,21 +32,10 @@ renderValue :: String -- ^ Key of which the value should be copied.
3332 -> String -- ^ Key the value should be copied to.
3433 -> (String -> String) -- ^ Function to apply on the value.
3534 -> HakyllAction Context Context
36−renderValue source destination f =
37− arr (Context . M.delete destination . unContext)
38− >>> renderMissingValue source destination f
39−
40−-- | Render a value, but do not overwrite the destination value if it already
41−-- exists.
42−--
43−renderMissingValue :: String -- ^ Source key
44− -> String -- ^ Destination key
45− -> (String -> String) -- ^ Function to apply on the value
46− -> HakyllAction Context Context
47−renderMissingValue source destination f = arr $ \(Context context) -> Context $
35+renderValue source destination f = arr $ \(Context context) -> Context $
4836 case M.lookup source context of
4937 Nothing -> context
50− (Just value) -> M.insertWith (flip const) destination (f value) context
38+ (Just value) -> M.insert destination (f value) context
5139
5240-- | Change a value in a @Context@.
5341--
src/Text/Hakyll/Page.hs+3
@@ -88,8 +88,11 @@ readPage path = do
8888 let sections = evalState (splitAtDelimiters $ lines contents) Nothing
8989 sectionsData = concat $ zipWith ($) sectionFunctions sections
9090
91+ -- Note that url, path etc. are listed first, which means can be overwritten
92+ -- by section data
9193 return $ PageSection ("url", url, False)
9294 : PageSection ("path", path, False)
95+ : PageSection ("title", takeBaseName path, False)
9396 : (category ++ sectionsData)
9497 where
9598 category = let dirs = splitDirectories $ takeDirectory path