From 7a765f29a2f5dcf753e5418c96a9c40ddb9112be Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Mon, 11 Jan 2010 10:02:33 +0100 Subject: Added $root in filepaths. --- examples/tagblog/hakyll.hs | 2 +- src/Text/Hakyll/File.hs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/tagblog/hakyll.hs b/examples/tagblog/hakyll.hs index 1476360..d30da26 100644 --- a/examples/tagblog/hakyll.hs +++ b/examples/tagblog/hakyll.hs @@ -58,7 +58,7 @@ main = hakyll $ do postManipulation = renderDate "date" "%B %e, %Y" "Date unknown" . renderTagLinks tagToURL - tagToURL tag = "/tags/" ++ removeSpaces tag ++ ".html" + tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html" renderPostList url title posts = do let postItems = renderAndConcatWith postManipulation diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs index ec9d0fb..d8ee8db 100644 --- a/src/Text/Hakyll/File.hs +++ b/src/Text/Hakyll/File.hs @@ -16,13 +16,17 @@ module Text.Hakyll.File import System.Directory import System.FilePath import Control.Monad +import Data.List (isPrefixOf) -- | Auxiliary function to remove pathSeparators form the start. We don't deal --- with absolute paths here. +-- with absolute paths here. We also remove $root from the start. removeLeadingSeparator :: FilePath -> FilePath removeLeadingSeparator [] = [] -removeLeadingSeparator p@(x:xs) | x `elem` pathSeparators = xs - | otherwise = p +removeLeadingSeparator path + | (head path') `elem` pathSeparators = (tail path') + | otherwise = path' + where path' = if "$root" `isPrefixOf` path then drop 5 path + else path -- | Convert a relative filepath to a filepath in the destination (_site). toDestination :: FilePath -> FilePath -- cgit v1.2.3