@@ -12,6 +12,7 @@ import Control.Monad (foldM)
1212import Text.Hakyll.Hakyll (Hakyll)
1313
1414import Text.Hakyll.Context (ContextManipulation, renderValue)
15+import Text.Hakyll.Render.Internal (finalSubstitute)
1516import Text.Hakyll.Regex
1617import Text.Hakyll.Util
1718import Text.Hakyll.Page
@@ -29,8 +30,8 @@ readTagMap paths = foldM addPaths M.empty paths
2930 return $ foldr (\t -> M.insertWith (++) t [path]) current tags
3031
3132-- | Render a tag cloud.
32−renderTagCloud :: M.Map String [FilePath] -- ^ A tag map as produced by 'readTagMap'.
33− -> (String -> String) -- ^ Function that produces an url for a tag.
33+renderTagCloud :: M.Map String [FilePath] -- ^ Map as produced by 'readTagMap'.
34+ -> (String -> String) -- ^ Function to produce an url for a tag.
3435 -> Float -- ^ Smallest font size, in percent.
3536 -> Float -- ^ Biggest font size, in percent.
3637 -> String -- ^ Result of the render.
@@ -38,10 +39,12 @@ renderTagCloud tagMap urlFunction minSize maxSize =
3839 intercalate " " $ map renderTag tagCount
3940 where
4041 renderTag :: (String, Float) -> String
41− renderTag (tag, count) = "<a style=\"font-size: "
42− ++ sizeTag count ++ "\" href=\""
43− ++ urlFunction tag ++ "\">"
44− ++ tag ++ "</a>"
42+ renderTag (tag, count) =
43+ finalSubstitute "<a style=\"font-size: $size\" href=\"$url\">$tag</a>" $
44+ M.fromList [ ("size", sizeTag count)
45+ , ("url", urlFunction tag)
46+ , ("tag", tag)
47+ ]
4548
4649 sizeTag :: Float -> String
4750 sizeTag count = show size' ++ "%"