summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text')
-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