Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-markdown-router

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-markdown-router

Express middleware for generating pages dynamically using markdown files

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 29 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc