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

v0.1.7

Published

Metalsmith plugin for adding created and updated attributes to files.

Downloads

1,020

Readme

metalsmith-updated

This is a plugin for Metalsmith that adds created and updated attributes to files based on cached information saved in a file.

Installation

This module is released via npm, install the latest released version with:

npm install --save metalsmith-updated

Usage

If using the CLI for Metalsmith, metalsmith-updated can be used like any other plugin by including it in metalsmith.json:

{
  "plugins": {
    "metalsmith-updated"
  }
}

For Metalsmith's JavaScript API, metalsmith-updated can be used like any other plugin, by attaching it to the function invocation chain on the metalscript object:

var updated = require('metalsmith-updated');
require('metalsmith')(__dirname)
  .use(updated())
  .build();

metalsmith-updated will only check HTML pages. Normally you will want to use the plugin as soon as your markup has been converted to HTML, but before it is templated, since these variables are useful in templates.

metalsmith-updated adds three attributes to each HTML file: created, and updated.

  • created: set if this is the first time that metalsmith-updated has seen the file.
  • updated: set if the file is new or if it's contents have changed.
  • modified: set if the file has been modified since it was created. This implies that created != modified.

metalsmith-updated identifies files by filename and changes by hashing file.contents. Timestamps are set to metadata.date if it exists (for compatibility with metalsmith-build-date), or to new Date() if not.

Note that metalsmith-updated will not override these attributes if they already exist on any file, but will save dutifully to its comparison file. This can be useful for bootstrapping metalsmith-updated for existing blog posts, for example.

Options

metalsmith-updated does not require any options, but the following options are available:

verbose (optional)

(default: false)

If set a message will be printed if files generate warnings or errors.

ignoreKeys (optional)

(default: ["draft"])

metalsmith-updated will ignore files that have "truthy" values in any of these keys.

filePatterns (optional)

(default: [])

A list of minimatch patterns to constrain the files that metalsmith-updated will examine. ["*.html"] is a potentially-useful option.

updatedFile (optional)

(default: .updated.json)

Path relative to the metalsmith source directory where metalsmith-updated caches file information. This will be removed from the build directory.