Giter VIP home page Giter VIP logo

markdown-doc-bundler's Introduction

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

markdown-doc-bundler's People

Contributors

scott-wyatt avatar wbprice avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.