summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Hakyll/File.hs1
-rw-r--r--src/Text/Hakyll/Util.hs8
2 files changed, 9 insertions, 0 deletions
diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs
index c535b11..0c803e1 100644
--- a/src/Text/Hakyll/File.hs
+++ b/src/Text/Hakyll/File.hs
@@ -50,6 +50,7 @@ getRecursiveContents topdir = do
-- | A filter that takes all file names with a given extension. Prefix the
-- extension with a dot:
+--
-- > havingExtension ".markdown" ["index.markdown", "style.css"] == ["index.markdown"]
havingExtension :: String -> [FilePath] -> [FilePath]
havingExtension extension = filter ((==) extension . takeExtension)
diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs
index d498281..319bed4 100644
--- a/src/Text/Hakyll/Util.hs
+++ b/src/Text/Hakyll/Util.hs
@@ -2,6 +2,7 @@ module Text.Hakyll.Util
( trim
, split
, stripHTML
+ , link
) where
import Data.Char (isSpace)
@@ -26,3 +27,10 @@ stripHTML str = let (beforeTag, rest) = break (== '<') str
split :: String -> String -> [String]
split pattern = filter (not . null)
. splitRegex (mkRegex pattern)
+
+-- | Make a HTML link.
+--
+-- > link "foo" "bar.html" == "<a href='bar.html'>foo</a>"
+link :: String -> String -> String
+link text destination = "<a href=\"" ++ destination ++ "\">"
+ ++ text ++ "</a>"