Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Metalsmith Default Values

npm version code style: prettier metalsmith: plugin

Build Status Known Vulnerabilities NSP Status Greenkeeper badge

Metalsmith Plugin for setting default front-matter metadata.

Uses multimatch for pattern matching.

Installation

npm install -S metalsmith-default-values

Note: -S switch saves the plugin to your package.json.

Usage:

1. Include the plugin

const default_values = require('metalsmith-default-values');

2. Use the plugin in your build pipeline

...
.use(default_values([
  {
    pattern : 'posts/*.md',
    defaults: {
      layout: 'post.hbs',
      date: function (post) {
        return post.stats.ctime;
      }
    }
  },
  {
    pattern : 'diary/*.md',
    defaults: {
      layout : 'diary.hbs',
      private: true
    }
  },
  {
    pattern : [
      'diary/*.md',
      'archive/**/*.md'
    ],
    defaults: {
      no_index: true
    }
  },
  {
    pattern : '**/*.md',
    defaults: {
      layout : 'default.hbs'
    }
  }
]))
...

3. Profit

GL HF

Node versions

Because Joi > v6 uses ES6 syntax this runs on NodeJS v4 and above.

Contributions

Make sure you have EditorConfig plugin for your editor.

npm test runs the tests, also uses ESLint and Prettier

License - GPL-3.0

metalsmith-default-values is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

metalsmith-default-values is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with metalsmith-default-values. If not, see http://www.gnu.org/licenses/.

About

Metalsmith Plugin for setting default frontmatter metadata

Resources

License

You can’t perform that action at this time.