MetalSmith-WordCloud
A metalsmith plugin that creates an array of weighted values for use in a word cloud.
This plugin needs to be used in conjunction with metalsmith-tags as the path for the cloud category can used to point to the html page listing of related articles. The metalsmith-tags plugin takes the string list of categories/tags and converts them to an array of values. The metalsmith-cloud plugin is dependent on this array that exists in each file object.
Cloud tags are sorted alphanumerically by tag name.
Installation
$ npm install metalsmith-cloud --save-dev
CLI Usage
Install the node modules and then add the metalsmith-tags
key to your metalsmith.json
plugins. The simplest use case just requires tag handle you want to use:
Javascript Usage
Pass the plugin to Metalsmith#use
:
var tags = wordcloud = ; metalsmith
Usage
Under The Covers
A property key 'cloud' is added to the metadata containing a sorted array of objects with 'ctg', 'wght' and 'pth' keys.
Application
Using handlebars the following example creates links for each category.
{{#each cloud}}
<a href="{{this.pth}}">
{{this.ctg}}({{this.wght}})
</a>
{{/each}}
where the html built would be as follows:
aws(1) bash(1) blog(1)
There are several implementations for creating word clouds. http://ericstiles.github.io uses jquery.tagcloud.js to create a wordcloud on the site.