Extends DocPad's tagging features by adding tag cloud generation
npm install --save docpad-plugin-tagcloud
Generate tag index pages for your documents as described in the Tags plugin.
The plugin adds the
@getTagCloud() template helper, which returns an object containing the tag cloud data of the form:
yellow:tag: "yellow" // the tag nameurl: "/tags/yellow" // URL of the tag index pagecount: 5 // number of documents containing the tagweight: 0.25 // weight of the tagblue:tag: "blue"url: "/tags/blue"count: 3weight: 0.12...
The following example iterates through the tag cloud and generates links to the tag index pages (in eco):
<% for tag, data of @getTagCloud(): %><a href="<%= data.url %>" data-tag-count="<%= data.count %>" data-tag-weight="<%= data.weight %>"><%= tag %></a><% end %>
Note that in this example we've added the count and weight here as HTML5 data fields so that a client-side script can apply the desired styling. You can of course do whatever you wish with the count or weight values, such as adding inline CSS for setting the font-size (but of course we don't do that kind of thing anymore right?)
By default, the tag weights are calculated using a simple logarithmic algorithm. If that isn't floating your proverbial boat you are free to override this function with the weight function of your choosing. For example in your docpad config you could add:
plugins:tagging:getTagWeight: (count, maxCount) ->return count/maxCount
count is the number of occurences of the tag, and
maxCount is the count of the tag with the highest number of occurrences.
You can discover the history inside the