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

docpad-plugin-tagging

v2.0.3

Published

DocPad plugin providing tag cloud generation and tag index pages

Downloads

3

Readme

Tagging Plugin for DocPad

Extends DocPad's tagging features by adding tag cloud generation and automatic tag index pages.

Compatibility

Please note that this plugin is not compatible with docpad > 6.57. Please use the new Tags Plugin instead for tag index page generation, along with the TagCloud Plugin for tag cloud generation.

Install

npm install --save docpad-plugin-tagging

Usage

Tag Cloud

Add tag metadata to your documents as described in the Related 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 name
	url: "/tags/yellow"		// URL of the tag index page
	count: 5					// number of documents containing the tag
	weight: 0.25				// weight of the tag
blue:
	tag: "blue"
	url: "/tags/blue"
	count: 3
	weight: 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?)

Index Pages

The plugin will also dynamically generate a document for each tag found with the url tags/[tagname].html. The index documents are created with the following metadata (by default):

---
layout: tags
tag: [tagname]
---

The plugin does not generate any content for the index pages. You are in complete control of what is displayed on the index pages via the layout file.

For example, let's create the following file at layouts/tags.html.eco to display a list of all documents that have the tag in question:

---
layout: default
---
<h1>Pages tagged with '<%= @document.tag %>'</h1>

<ul>
<% for doc in @getCollection('documents').findAll({tags: '$in': @document.tag}).toJSON(): %>
    <li><a href="<%= doc.url %>"><%= doc.title %></a></li>
<% end %>
</ul>

The plugin also adds a @getTagUrl(tagname) template helper so you can easily get the URL of the index page for a particular tag. For example, in your templates you could display a list of the document's tags as links to their index page (this time in coffeekup just to keep life interesting):

---
title: "Random document"
layout: default
tags:
 - blarky
 - snargle
 - floopy
---
h2 -> "My Tags"
ul ->
    for tag in @document.tags
        li -> a href: @getTagUrl(tag), -> tag

Options

  • collectionName : Can be used to narrow the scope of the plugin to a specific collection and therefore improve performance (defaults to 'documents').
  • indexPageLayout : Override the name of the layout file used for the tag index pages (defaults to 'tags').
  • indexPagePath : Override the relative output path of the tag index pages (defaults to 'tags').
  • indexPageLowercase : If true, generated tag index page filenames will be forced to lowercase (defaults to false).
  • getTagWeight : Override the function used to generate the tag weights (see below).

Customising the weight function

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

Here count is the number of occurences of the tag, and maxCount is the count of the tag with the highest number of occurrences.

History

You can discover the history inside the History.md file

License

Licensed under the incredibly permissive MIT License Copyright © 2013 Richard Antecki