🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

metalsmith-just-a-moment

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metalsmith-just-a-moment

A Metalsmith plugin to auto convert dates to moment objects.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Metalsmith Just A Moment

A Metalsmith plugin which automatically converts all dates in files and metadata to moment.js objects.

Explanation

Automatically converting all your date objects to moment.js objects allows you to have very simple access to moment.js formatting inside your templates.

Install

npm install metalsmith-just-a-moment --save

Example

metalsmith.json config example:

{
  "plugins": {
    // These are the default metalsmith-just-a-moment options, shown here only for demonstration.
    "metalsmith-just-a-moment": {
      pattern: ['**/*.md'],
      scanFiles: true,
      scanMetadata: true
    }
  }
}

Build script example:

var metalsmith = require('metalsmith');
var markdown = require('metalsmith-markdown');
var justAMoment = require('metalsmith-just-a-moment');


metalsmith(__dirname)
  .source('src')
  .destination('pub')
  // These are the default metalsmith-just-a-moment options, shown here only for demonstration.
  .use(justAMoment({
    pattern: ['**/*.md'],
    scanFiles: true,
    scanMetadata: true
  }))
  .use(markdown({
    gfm: true,
    tables: true
  }))
  .build(function (err) {
    if (err) {
      throw err;
    }
  });
  

Options

  • pattern
    • Default value: ['**/*.md']
    • Description: Only process files that match this pattern, can be an array of multiple patterns, following multimatch rules.
  • scanFiles
    • Default value: true
    • Description: Should scan files for dates.
  • scanMetadata
    • Default value: true
    • Description: Should scan metadata object for dates.
  • asUTC
    • Default value: false
    • Description: Parse dates as UTC. If your date has a timezone it will be subtracted to get UTC, otherwise your date will be assumed to be UTC.

Caveat

metalsmith-permalinks won't like that your dates are already moment.js objects, if you are using metalsmith-permalinks use metalsmith-just-a-moment after, not before, or use a patched version of metalsmith-permalinks (with other fixes) here.

Keywords

metalsmith

FAQs

Package last updated on 19 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts