GithubHelp home page GithubHelp logo

vellengs / express-markdown-router Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iamstuartwilson/express-markdown-router

0.0 2.0 0.0 6 KB

Express middleware for generating pages dynamically using markdown files

JavaScript 100.00%

express-markdown-router's Introduction

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.

express-markdown-router's People

Contributors

germanattanasio avatar iamstuartwilson 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.