0.0.13 • Published 8 years ago

markdown-doc-bundler v0.0.13

Weekly downloads
15
License
MIT
Repository
github
Last release
8 years ago

markdown-doc-bundler

Accepts the path of a directory. Produces an object containing the contents of markdown files as strings organized according to the directory's original structure.

Usage

Installation

  npm install --save markdown-doc-bundler

Bundler

Given a path to a directory containing markdown files organized like this:

  README.md
  - anatomy
  -- README.md
  -- backbone.md
  -- kneebone.md
  -- tailbone.md
  --- trailsProject
  ---- README.md
  --- api
  ---- README.md
  - concepts
  -- README.md

Returns an object that looks like this:

{
  'README.md': 'This is a markdown file',
  'anatomy': {
    'trailsProject': {
      'README.md': 'A different markdown file',
      'backbone.md': 'Backbone is a client side JavaScript framework',
      'kneebone.md': 'The kneebone is connected to the ankle bone',
      'tailbone.md': 'The tailbone is connected to the backbone',
      'api': {
        'README.md': 'A totally new thing'
      }
    },
    'README.md': 'Bomb diggity'
  },
  'concepts': {
    'concepts.md': 'Last markdown file, I promise.'
  }
}
Usage
  const markdownDocBundler = require('markdown-doc-bundler').bundler
  const docs = markdownDocBundler(/* absolute path to directory */)

Routes Maker

Given input that looks like this:

{
  'README.md': 'This is a markdown file',
  'anatomy': {
    'trailsProject': {
      'README.md': 'A different markdown file',
      'backbone.md': 'Backbone is a client side JavaScript framework',
      'kneebone.md': 'The kneebone is connected to the ankle bone',
      'tailbone.md': 'The tailbone is connected to the backbone',
      'api': {
        'README.md': 'A totally new thing'
      }
    },
    'README.md': 'Bomb diggity'
  },
  'concepts': {
    'concepts.md': 'Last markdown file, I promise.'
  }
}

Returns output that look like:

[
  [ '/', 'This is a markdown file' ],
  [ '/anatomy/', 'Bomb diggity' ],
  [ '/anatomy/backbone', 'Backbone is a client side JavaScript framework'],
  [ '/anatomy/kneebone', 'The kneebone is connected to the ankle bone'],
  [ '/anatomy/tailbone', 'The tailbone is connected to the backbone'],
  [ '/anatomy/trailsProject/', 'A different markdown file' ],
  [ '/anatomy/trailsProject/api', 'A totally new thing' ],
  [ '/concepts/', 'Last markdown file, I promise.' ]
}

This allows us to create routes on the server based on the structure of the directory containing our documentation, passing the contents of the markdown files as context to the views.

Usage
  const docs = markdownDocBundler(/* absolute path to directory */)
  const routesMaker = require('markdown-doc-bundler').routesMaker
  const routes = routesMaker(docs)

Tests

  npm test
0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago