Find posts recursively within a subdirectory, and parse their front matter


Keywords
file, directory, front, matter, yaml, json, markdown
License
GPL-3.0
Install
npm install find-posts@0.5.0

Documentation

find-posts

Finds and parses posts in specific directories with specific names.

Installation

npm i --save find-posts

Usage

const findAllPosts = require('find-posts/find-all-posts.js');

findAllPosts({
  dirs: [
    {
      path: path.resolve(cwd, './posts/foo/'),
      regexes: [ /^(\d\d\d\d)-(\d\d)-(\d\d)-(.*)\.html\.md$/; ],
    },
    {
      path: path.resolve(cwd, './posts/bar/'),
      regexes: [ /^(.+)\.html$/ ],
    }
  ],
})
.then((data) => {
  // look in data for posts
});

A post is any file whose name matches the specified pattern, found within the speicified directory, and contains front matter that is parseable by front-matter.

Author

Brendan Graetz

Licence

GPL-3.0