Simple docs for apps with markdown
simple docs for apps with markdown
$ npm install markdocs -g
$ markdocs create
Start the server:
$ node app
$ markdocs create docs -e
Initialize the docs app from your express app:
var express = require'express';var app = express;appget'/'ressend'Hello World';;var markdocs = require'markdocs';var docsapp = markdocsApp'/docs' app;applisten3000;
var options =basePath: '/docs'useDefaultProcessors: false;var docsapp = markdocsAppoptions app;// Add a custom processordocsappaddDocumentProcessor// Do your processingtext = textreplace'!something' '<span>This is a wierd shortcut.</span>';return text;;// Add back the default processors after our first onedocsappaddDocumentProcessormarkdocsProcessorsjs;docsappaddDocumentProcessormarkdowsProcessorsmarkdown;
Markdocs supports the consumption of HTML content outside of the main side (for example embedding on a second site or using them in a SPA). You must set the options yourself from your host application as shown.
To return just the article HTML
Use embedded view:
response.locals.embedded = true;
You must also provide a
doc.embedded.jade template view in your theme. Typically this view looks like the following, but you may want to customize it.
TO return the article data as JSON/JSONP
You must still provide the embedded view as shown above. In addition you can set the following.
response.locals.json = true or
response.locals.jsonp = true.
Finally, in the JSON responses you can optionally include metadata by specifiying:
response.locals.include_metadata = true;
The easiest way to use all of these in your app is to add a prerender middleware to your markdocs app as follows.
varreslocalsembedded = false;reslocalsinclude_metadata = false;if reqquerye || reqquerycallbackreslocalsembedded = true;if reqquerymreslocalsinclude_metadata = true;if reqquerycallbackreslocalsjsonp = true;else if !reqaccepts'html' && reqaccepts'application/json'reslocalsjson = true;next;;docsappaddPreRenderembedded;## Issue ReportingIf you have found a bug or if you have a feature request please report them at this repository issues section Please do not report security vulnerabilities on the public GitHub issue tracker The Responsible Disclosure Programhttps://auth0.com/whitehat) details the procedure for disclosing security issues.## AuthorAuth0auth0com## LicenseThis project is licensed under the MIT license See the LICENSELICENSE file for more info