Skip to content

Find posts recursively within directories, and parse their front matter

Notifications You must be signed in to change notification settings

bguiz/find-posts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Find posts recursively within directories, and parse their front matter

Resources

Stars

Watchers

Forks

Packages

No packages published