Hi Fred,
We'll abuse `splitExtension` from `System.FilePath` a bit -- it's really
supposed to work on file paths, but if we're just taking an extension it
also works on URLs.
import System.FilePath (splitExtension)
Hakyll provides a utility function `withUrls`, which allows you map a
`String -> String` function over the URLs in an HTML page.
htmlizeUrls :: Item String -> Compiler (Item String)
htmlizeUrls = return . fmap (withUrls htmlize)
Lastly, we want to use an extra guard with `isExternal` from Hakyll.
This prevents us from changing external links like
`
http://github.com/foo/bar/some-file.md`; we only want to change links
within our website.
where
htmlize :: String -> String
htmlize url = case splitExtension url of
_ | isExternal url -> url
(name, ".md") -> name ++ ".html"
_ -> url
Hope this helps!
Jasper
> --
> You received this message because you are subscribed to the Google Groups "hakyll" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
hakyll+un...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/hakyll/77ab1343-5a3c-4d28-bd09-a6bcf30ab36c%40googlegroups.com.