diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-17 12:14:54 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-17 12:14:54 +0100 |
commit | 003734442486876153911d339f07d4379e8dca20 (patch) | |
tree | 6ec2fde774586175efefac0198e142d6312e618e /src | |
parent | 6bacab4f22213df62d6162296a209173701171b8 (diff) | |
download | hakyll-003734442486876153911d339f07d4379e8dca20.tar.gz |
Use Text.Hakyll.Render.Internal to render tag cloud.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Hakyll/Tags.hs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Text/Hakyll/Tags.hs b/src/Text/Hakyll/Tags.hs index 209d479..667c2ee 100644 --- a/src/Text/Hakyll/Tags.hs +++ b/src/Text/Hakyll/Tags.hs @@ -12,6 +12,7 @@ import Control.Monad (foldM) import Text.Hakyll.Hakyll (Hakyll) import Text.Hakyll.Context (ContextManipulation, renderValue) +import Text.Hakyll.Render.Internal (finalSubstitute) import Text.Hakyll.Regex import Text.Hakyll.Util import Text.Hakyll.Page @@ -29,8 +30,8 @@ readTagMap paths = foldM addPaths M.empty paths return $ foldr (\t -> M.insertWith (++) t [path]) current tags -- | Render a tag cloud. -renderTagCloud :: M.Map String [FilePath] -- ^ A tag map as produced by 'readTagMap'. - -> (String -> String) -- ^ Function that produces an url for a tag. +renderTagCloud :: M.Map String [FilePath] -- ^ Map as produced by 'readTagMap'. + -> (String -> String) -- ^ Function to produce an url for a tag. -> Float -- ^ Smallest font size, in percent. -> Float -- ^ Biggest font size, in percent. -> String -- ^ Result of the render. @@ -38,10 +39,12 @@ renderTagCloud tagMap urlFunction minSize maxSize = intercalate " " $ map renderTag tagCount where renderTag :: (String, Float) -> String - renderTag (tag, count) = "<a style=\"font-size: " - ++ sizeTag count ++ "\" href=\"" - ++ urlFunction tag ++ "\">" - ++ tag ++ "</a>" + renderTag (tag, count) = + finalSubstitute "<a style=\"font-size: $size\" href=\"$url\">$tag</a>" $ + M.fromList [ ("size", sizeTag count) + , ("url", urlFunction tag) + , ("tag", tag) + ] sizeTag :: Float -> String sizeTag count = show size' ++ "%" |