GitXplorerGitXplorer
i

express-markdown-router

public
5 stars
4 forks
0 issues

Commits

List of commits on branch master.
Unverified
d2057c35f9df3d1838c6656ec281539b6bf37432

Bump to `v 1.1.0`

iiamstuartwilson committed 9 years ago
Unverified
d4cfd0dccb58bcc1713628448f91f63d08949844

Merge pull request #1 from germanattanasio/master

iiamstuartwilson committed 9 years ago
Unverified
fd06bc7d636ca267b2e749e276e19b6f303b759e

switch to marked

ggermanattanasio committed 9 years ago
Unverified
c05c63684d848de932fe1384a4b4d69ed111ff74

Add syntax highlighting to readme

iiamstuartwilson committed 10 years ago
Unverified
be44e3f50d08cf8bbdb817aa128639918a3658b8

Fix typo

committed 10 years ago
Unverified
a0ff46b5160faa57e2e55692e94cff9bd75a40f1

Added repo and updated ignore file

committed 10 years ago

README

The README file for this repository.

express-markdown-router

Express middleware for generating pages dynamically using markdown files. Say goodbye to explicitly bootstrapping routes in your Express app!

Installation

npm install express-markdown-router

Quick Start

You must be using an Express template engine to use this middleware

var express = require('express');
var markdownRouter = require('express-markdown-router');

var app = express();

app.set('port', process.env.PORT || 3000);

// Using the jade template engine
app.set('view engine', 'jade');

// Use the markdownRouter middleware and pass the directory of your .md files
app.use(markdownRouter(__dirname + '/pages'));

app.listen(app.get('port'), function() {
    console.log('Server started on port %d', app.get('port'));
});

This will start a server and build an index of routes based on the .md files found in the ./pages dir

It will then send the local var markdown from the parsed markdown file inside the index[.ext] view.

Routing

Currently there is one special route: index.md will map to the root path '/'

All other routes will map page.md to /page and page.subpage.md to /page/subpage and so on...

Additional Params

The view used to render the markdown files within will default to index[.ext]. You can change this by passing a second param to the middleware:

// Uses a view called 'markdown'
app.use(markdownRouter(__dirname + '/pages', 'markdown'));

Caching

All routes are cached on server start, but in development, the contents of the .md files will not be so you can freely update your pages on the fly before deploying them.