summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-08 12:41:58 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-08 12:41:58 +0100
commit699bd0011e9771cd5c03c65aec0ec79656c475a1 (patch)
tree8b2840edb78336d0de293744bc79bb96a14be29b /src/Text/Hakyll
parentb403d35b087683a7a38e57b943c63449613b3115 (diff)
downloadhakyll-699bd0011e9771cd5c03c65aec0ec79656c475a1.tar.gz
Added tagblog example (tutorial coming up).
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r--src/Text/Hakyll/File.hs18
-rw-r--r--src/Text/Hakyll/Tags.hs3
2 files changed, 18 insertions, 3 deletions
diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs
index 0c803e1..400d156 100644
--- a/src/Text/Hakyll/File.hs
+++ b/src/Text/Hakyll/File.hs
@@ -4,6 +4,7 @@ module Text.Hakyll.File
( toDestination
, toCache
, toURL
+ , removeSpaces
, makeDirectories
, getRecursiveContents
, havingExtension
@@ -15,18 +16,31 @@ import System.Directory
import System.FilePath
import Control.Monad
+-- | Auxiliary function to remove pathSeparators form the start. We don't deal
+-- with absolute paths here.
+removeLeadingSeparator :: FilePath -> FilePath
+removeLeadingSeparator [] = []
+removeLeadingSeparator p@(x:xs) | x `elem` pathSeparators = xs
+ | otherwise = p
+
-- | Convert a relative filepath to a filepath in the destination (_site).
toDestination :: FilePath -> FilePath
-toDestination path = "_site" </> path
+toDestination path = "_site" </> (removeLeadingSeparator path)
-- | Convert a relative filepath to a filepath in the cache (_cache).
toCache :: FilePath -> FilePath
-toCache path = "_cache" </> path
+toCache path = "_cache" </> (removeLeadingSeparator path)
-- | Get the url for a given page.
toURL :: FilePath -> FilePath
toURL = flip addExtension ".html" . dropExtension
+-- | Swaps spaces for '-'.
+removeSpaces :: FilePath -> FilePath
+removeSpaces = map swap
+ where swap ' ' = '-'
+ swap x = x
+
-- | Given a path to a file, try to make the path writable by making
-- all directories on the path.
makeDirectories :: FilePath -> IO ()
diff --git a/src/Text/Hakyll/Tags.hs b/src/Text/Hakyll/Tags.hs
index c64d566..ea9ee87 100644
--- a/src/Text/Hakyll/Tags.hs
+++ b/src/Text/Hakyll/Tags.hs
@@ -56,5 +56,6 @@ renderTagCloud tagMap urlFunction minSize maxSize =
renderTagLinks :: (String -> String) -- ^ Function that produces an url for a tag.
-> ContextManipulation
renderTagLinks urlFunction = renderValue "tags" "tags" renderTagLinks'
- where renderTagLinks' = B.pack . intercalate ", " . map urlFunction
+ where renderTagLinks' = B.pack . intercalate ", "
+ . map (\t -> link t $ urlFunction t)
. map trim . split "," . B.unpack