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-mallet

v0.2.0

Published

A Metalsmith plugin to build Jekyll style posts.

Downloads

14

Readme

metalsmith-mallet

A mallet is typically used to form sheet metal as well as for forcing tight-fitting parts together. The metalsmith-mallet plugin is used to force together Metalsmith and Jekyll or any other static site generator that uses Jekyll style posts.

I like the idea behind Metalsmith. It's simplicity and pluggable architecture is very alluring, but I am still a big fan of Jekyll, therefore I wanted an option to keep my posts unchanged so that I could use both of these tools to generate my blog.

Installation

Install using NPM.

npm install metalsmith-mallet

Or add to the package.json file.

"dependencies": {
  "metalsmith-mallet": "*"
}

Usage

It is very important to run metalsmith-mallet before any other plugins. Otherwise your posts might not be processed correctly.

CLI Usage

Install via npm and then add the metalsmith-mallet key to your metalsmith.json plugins.

{
  "plugins": {
    "metalsmith-mallet": true
  }
}

JavaScript Usage

var mallet     = require('metalsmith-mallet'),
    markdown   = require('metalsmith-markdown'),
    metalsmith = require('metalsmith');

Metalsmith(__dirname)
  .use(mallet())
  .use(markdown())
  .build();

Ignore option

In case there are any posts that you don't want to process with metalsmith-mallet, you can specify them using ignore option.

Metalsmith(__dirname)
    .use(mallet({ ignore: ["2014-04-05-random-post.md"] }))
    .use(markdown())
    .build();

Collection option

metalsmith-mallet makes it easier to use metalsmith-collections plugin without changing the metadata of your posts by adding a collection property. The default value is the same as layout, but you can change it using collection option.

Metalsmith(__dirname)
    .use(mallet({ collection: "articles" }))
    .use(markdown())
    .build();

In addition to properties defined in the YAML Front Matter metalsmith-mallet defines url and date, so in a Handlebars template you can do something like this:

<time>{{ date }}</time>
<h1><a href="{{ url }}" title="{{ title }}">{{ title }}</a></h1>

The value for the date is taken from the post's file name, therefore it has a format of yyyy-mm-dd. If you want to change the format, you should define a helper function for that. If you are using Handlebars, the helper function might look something like this.

Handlebars.registerHelper('localeDateFrom', function (dateString) {
    var date = new Date(dateString);

    return date.toLocaleDateString();
});

Then you can use this function in a template.

<time>{{localeDateFrom date}}</time>

TODO:

  • Add an option to specify a different permalink format.

If you have any thoughts on this project, you can find me on Twitter as @aigarsdz.