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

broccoli-front-matter-filter

v0.2.1

Published

Broccoli plugin to filter files based on parsed front matter

Downloads

13

Readme

Broccoli Front Matter Filter

A Broccoli plugin that includes or excludes files from the destination tree based on the values of front matter in the individual files.

Installation

npm install --save-dev broccoli-front-matter-filter

Usage

Assume files with the following content:

  • src/ios.md
---
mobile: true
---

## Hello from the phone.
  • src/windoz.md
---
desktop: true
---

## Hello from the desktop

Including 'desktop' files:

var filterFrontMatter = require('broccoli-front-matter-filter');

var tree = filterFrontMatter('src', {
  include: function(frontMatter) {
    return frontMatter.desktop === true;
  }
});
// tree will include 'src/windoz.md'

Documentation

filterFrontMatter(inputTree, options)


options.include {Function}

A callback that is passed the value of the parsed front matter. If the callback returns a truthy value, then the file will be included in the destination tree. Otherwise, it will not.


options.removeIfNoFrontMatter {Boolean}

What to do when a file does not include front matter. If true, the file will not be included in the destination tree. Default: false


options.stripFrontMatter {Boolean}

If true, front matter will be removed from the file before going to the destination tree. Otherwise, the file will be left alone. Note, caching is not implemented in this library yet which means values of true will modify any files with front matter. The result is slower incremental rebuild time that increases as the number of files with front matter increases. Until caching is implemented, it is recommended to keep this value set to false. Default: false


options.grayMatter {Object}

This uses gray-matter for front matter parsing. Gray matter supports additional features like configuring the type of front matter, evaluating the front matter, if you wish to use coffeescript or javascript, and specifying different delimiters (amongst other features). Any options provided here will be passed through to the gray matter parser. So, to support multiple types of front matter delimiters, you could do:

var tree = filterFrontMatter('src', {
  grayMatter: {
    delims: [ '\\/\\*\\* yaml', '\\*\\*\\/' ]
  },
  include: function(frontMatter) {
    return frontMatter.desktop === true;
  }
});

Note: the delims are converted to regular expressions. If you wish to use characters that are reserved in regular expressions as delimiters, then you must escape them both from the defining string and to the regular expression (hence the double backslashes).