summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Urls
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-11-18 21:56:52 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-11-18 21:56:52 +0100
commit877cb21d1630d32c6e40eb7c6f0ecc7e1da2bd52 (patch)
tree57ce11325adbbb7502086450dd1d1a9f1e81b8f2 /src/Hakyll/Web/Urls
parent1347b0fa6cdd98986f927368e76e849068f69e1a (diff)
downloadhakyll-877cb21d1630d32c6e40eb7c6f0ecc7e1da2bd52.tar.gz
Add Item abstraction
Diffstat (limited to 'src/Hakyll/Web/Urls')
-rw-r--r--src/Hakyll/Web/Urls/Relativize.hs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Hakyll/Web/Urls/Relativize.hs b/src/Hakyll/Web/Urls/Relativize.hs
index 068ae09..321bbe3 100644
--- a/src/Hakyll/Web/Urls/Relativize.hs
+++ b/src/Hakyll/Web/Urls/Relativize.hs
@@ -15,8 +15,8 @@
--
-- > <img src="../images/lolcat.png" alt="Funny zomgroflcopter" />
module Hakyll.Web.Urls.Relativize
- ( relativizeUrlsCompiler
- , relativizeUrls
+ ( relativizeUrls
+ , relativizeUrlsWith
) where
@@ -26,27 +26,27 @@ import Data.List (isPrefixOf)
--------------------------------------------------------------------------------
import Hakyll.Core.Compiler
-import Hakyll.Web.Page
+import Hakyll.Core.Item
import Hakyll.Web.Urls
--------------------------------------------------------------------------------
-- | Compiler form of 'relativizeUrls' which automatically picks the right root
-- path
-relativizeUrlsCompiler :: Page -> Compiler Page
-relativizeUrlsCompiler page = do
- route <- getRoute
+relativizeUrls :: Item String -> Compiler (Item String)
+relativizeUrls item = do
+ route <- getRoute $ itemIdentifier item
return $ case route of
- Nothing -> page
- Just r -> relativizeUrls (toSiteRoot r) page
+ Nothing -> item
+ Just r -> fmap (relativizeUrlsWith $ toSiteRoot r) item
--------------------------------------------------------------------------------
-- | Relativize URL's in HTML
-relativizeUrls :: String -- ^ Path to the site root
- -> Page -- ^ HTML to relativize
- -> Page -- ^ Resulting HTML
-relativizeUrls root = withUrls rel
+relativizeUrlsWith :: String -- ^ Path to the site root
+ -> String -- ^ HTML to relativize
+ -> String -- ^ Resulting HTML
+relativizeUrlsWith root = withUrls rel
where
isRel x = "/" `isPrefixOf` x && not ("//" `isPrefixOf` x)
rel x = if isRel x then root ++ x else x