markdown-reader

    1.1.0 • Public • Published

    markdown-reader

    Create a stream of markdown files from a set of directories.

    npm travis standard conduct

    About

    markdown-reader is a library for reading a collection of markdown files, and making them easy to use in tools like static site generators.

    • urls are rewritten (optionally) from github-style relative links to absolute links appropriate for static html
    • frontmatter yaml is parsed into an object
    • markdown is transformed into html

    An example item in the stream:

    {
      basename: 'index.js',
      relname: 'tests/index.js',
      root: '/Users/sdv/workspace/sethvincent/folder-reader',
      filepath: '/Users/sdv/workspace/sethvincent/folder-reader/tests/index.js',
      stat: [fs.Stat Object],
      type: 'file', // or 'directory',
      file: '', // the original contents of the file
      markdown: '', // the markdown content without frontmatter
      data: {}, // an object containing any values from frontmatter
      html: '' // the markdown transformed into html
    }

    Install

    npm install --save markdown-reader

    Usage

    var path = require('path')
    var reader = require('markdown-reader')
     
    var dir = path.join(__dirname, 'files')
    reader(dir).on('data', console.log)

    Using alternate fs implementations

    You can use this module with alternate fs implementations like hyperdrive by passing the alternate fs as an option:

    var reader = require('markdown-reader')
    var hyperdrive = require('hyperdrive')
     
    var drive = hyperdrive('./drive')
     
    reader('/some/dir', { fs: drive })

    Documentation

    Examples

    Contributing

    Contributions are welcome! Please read the contributing guidelines first.

    Conduct

    It is important that this project contributes to a friendly, safe, and welcoming environment for all. Read this project's code of conduct

    Changelog

    Read about the changes to this project in CHANGELOG.md. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

    Contact

    License

    ISC

    Install

    npm i markdown-reader

    DownloadsWeekly Downloads

    1

    Version

    1.1.0

    License

    ISC

    Last publish

    Collaborators

    • sethvincent