diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-11 10:02:33 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-11 10:02:33 +0100 |
commit | 7a765f29a2f5dcf753e5418c96a9c40ddb9112be (patch) | |
tree | 8eaf3bd1156022177202e4037f5e54a6bc64dc71 | |
parent | eb1fe136880e24836ef08746f2bd96258c35e3df (diff) | |
download | hakyll-7a765f29a2f5dcf753e5418c96a9c40ddb9112be.tar.gz |
Added $root in filepaths.
-rw-r--r-- | examples/tagblog/hakyll.hs | 2 | ||||
-rw-r--r-- | 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 |