metalsmith-filter

1.0.2 • Public • Published

metalsmith-filter Build Status

A Metalsmith plugin for filtering source files

I wanted a function that worked the opposite of Metalsmith's ignore() function. This plugin will filter out files that don't match the supplied glob patterns. As a side effect of using multimatch instead of minimatch, you can use it as a replacement for Metalsmith.ignore for multiple patterns instead of calling ignore multiple times.

Install

npm install metalsmith-filter

Usage

Simply pass a single pattern or array of patterns, à la multimatch. You can optionally pass a second pattern of options as per minimatch instructions.

Process only Markdown files.

var filter = require('metalsmith-filter');
 
Metalsmith(__dirname)
    .use(filter('**/*.md'))
    .build();

Process anything but images.

var filter = require('metalsmith-filter');
 
Metalsmith(__dirname)
    .use(filter([ '*', '!**/*.jpg', '!**/*.gif', '!**/*.png', '!**/*.webp' ]))
    .build();

Pass options to minimatch.

var filter = require('metalsmith-filter');
 
Metalsmith(__dirname)
    .use(filter('*.html', { debug: true }))
    .build();

License

MIT © Anthony Castle

Readme

Keywords

none

Package Sidebar

Install

npm i metalsmith-filter

Weekly Downloads

320

Version

1.0.2

License

MIT

Last publish

Collaborators

  • mrajo