diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-11-14 22:48:48 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-11-14 22:48:48 +0100 |
commit | 1b5a0220f99742586e8c2c498f8ad878cddd30dd (patch) | |
tree | abc8240d3a89f7441103a2eedc91050c306ec5e1 | |
parent | 50459dcad88df2900cc23f4a9877da47c3c3af20 (diff) | |
download | hakyll-1b5a0220f99742586e8c2c498f8ad878cddd30dd.tar.gz |
Add default title
-rw-r--r-- | src/Text/Hakyll/ContextManipulations.hs | 18 | ||||
-rw-r--r-- | src/Text/Hakyll/Page.hs | 3 |
2 files changed, 6 insertions, 15 deletions
diff --git a/src/Text/Hakyll/ContextManipulations.hs b/src/Text/Hakyll/ContextManipulations.hs index f73e88c..1c26f72 100644 --- a/src/Text/Hakyll/ContextManipulations.hs +++ b/src/Text/Hakyll/ContextManipulations.hs @@ -2,7 +2,6 @@ -- manipulate @Context@s. module Text.Hakyll.ContextManipulations ( renderValue - , renderMissingValue , changeValue , changeUrl , copyValue @@ -14,7 +13,7 @@ module Text.Hakyll.ContextManipulations ) where import Control.Monad (liftM) -import Control.Arrow (arr, (>>>)) +import Control.Arrow (arr) import System.Locale (TimeLocale, defaultTimeLocale) import System.FilePath (takeFileName, addExtension, dropExtension) import Data.Time.Format (parseTime, formatTime) @@ -33,21 +32,10 @@ renderValue :: String -- ^ Key of which the value should be copied. -> String -- ^ Key the value should be copied to. -> (String -> String) -- ^ Function to apply on the value. -> HakyllAction Context Context -renderValue source destination f = - arr (Context . M.delete destination . unContext) - >>> renderMissingValue source destination f - --- | Render a value, but do not overwrite the destination value if it already --- exists. --- -renderMissingValue :: String -- ^ Source key - -> String -- ^ Destination key - -> (String -> String) -- ^ Function to apply on the value - -> HakyllAction Context Context -renderMissingValue source destination f = arr $ \(Context context) -> Context $ +renderValue source destination f = arr $ \(Context context) -> Context $ case M.lookup source context of Nothing -> context - (Just value) -> M.insertWith (flip const) destination (f value) context + (Just value) -> M.insert destination (f value) context -- | Change a value in a @Context@. -- diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs index 347e10a..f2b5fde 100644 --- a/src/Text/Hakyll/Page.hs +++ b/src/Text/Hakyll/Page.hs @@ -88,8 +88,11 @@ readPage path = do let sections = evalState (splitAtDelimiters $ lines contents) Nothing sectionsData = concat $ zipWith ($) sectionFunctions sections + -- Note that url, path etc. are listed first, which means can be overwritten + -- by section data return $ PageSection ("url", url, False) : PageSection ("path", path, False) + : PageSection ("title", takeBaseName path, False) : (category ++ sectionsData) where category = let dirs = splitDirectories $ takeDirectory path |