npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metalsmith-wordcloud

v0.0.4

Published

Groups posts based on categories in articles by attaching an array of the tags with their associated weights to the metalsmith metadata object.

Downloads

7

Readme

Build Status

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:

{
  "plugins": {
    "metalsmith-cloud": {
      "handle": "tags",
      "path": "topics",
      "reverse": true
    }
  }
}

Javascript Usage

Pass the plugin to Metalsmith#use:

var tags = require('metalsmith-tags'),
wordcloud = require('metalsmith-cloud');

metalsmith
    .use(tags({
        handle: 'tags',
        path: 'topics',
        template: '/partials/tag.hbt'
    }))
    .use(wordcloud({
        category: 'tags', //optional, default is tags
        reverse: false, //optional sort value on category, default is false
        path: '/topics' // <- Notice that path is prefixed with slash for absolute path 
    }))

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.

    {cloud: 
    [ { ctg: 'aws', wght: 1, pth: '/topics/aws' },
     { ctg: 'bash', wght: 1, pth: '/topics/bash' },
     { ctg: 'blog', wght: 2, pth: '/topics/blog' } ] }

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:

    <a href="/topics/aws">aws(1)</a>
    <a href="/topics/bash">bash(1)</a>
    <a href="/topics/blog">blog(1)</a>

There are several implementations for creating word clouds. http://ericstiles.github.io uses jquery.tagcloud.js to create a wordcloud on the site.