-- | Module containing some specialized functions to deal with tags.moduleText.Hakyll.Tags(readTagMap,renderTagCloud)whereimportqualifiedData.MapasMimportqualifiedData.ByteString.Lazy.Char8asBimportqualifiedData.ListasLimportControl.Monad(foldM)importText.Hakyll.UtilimportText.Hakyll.PageimportControl.Arrow(second)-- | Read a tag map. This creates a map from tags to page paths. This function-- assumes the tags are located in the `tags` metadata field, separated by-- commas.readTagMap::[FilePath]->IO(M.MapString[FilePath])readTagMappaths=foldMaddPathsM.emptypathswhereaddPathscurrentpath=dopage<-readPagepathlettags=maptrim$split","$B.unpack$getValue("tags")pagereturn$foldr(\t->M.insertWith(++)t[path])currenttags-- | Render a tag cloud.renderTagCloud::M.MapString[FilePath]-- ^ A tag map as produced by 'readTagMap'.->(String->String)-- ^ Function that produces an url for a tag.->Float-- ^ Smallest font size, in percent.->Float-- ^ Biggest font size, in percent.->String-- ^ Result of the render.renderTagCloudtagMapurlFunctionminSizemaxSize=L.intercalate" "$maprenderTagtagCountwhererenderTag::(String,Float)->StringrenderTag(tag,count)="<a style=\"font-size: "++sizeTagcount++"\" href=\""++urlFunctiontag++"\">"++tag++"</a>"sizeTag::Float->StringsizeTagcount=showsize'++"%"wheresize'::Intsize'=floor(minSize+(relativecount)*(maxSize-minSize))minCount=minimum$mapsnd$tagCountmaxCount=maximum$mapsnd$tagCountrelativecount=(count-minCount)/(maxCount-minCount)tagCount::[(String,Float)]tagCount=map(second$fromIntegral.length)$M.toListtagMap