Releases: lyphtec/markdown-serve
Releases · lyphtec/markdown-serve
v0.8.0
Fixed "headers can't be sent" errors when using preParse=true
hbs & express-handlebars view engines were throwing weird headers can't be sent
errors - something to do with async processing when calling markdownFile.parseContent(). This has now been resolved by removing the res.render()
call within parseContent()
.
Fixed issue with hbs view engine when using res.end()
Removed all res.end()
calls as these were causing issues when using the hbs
view engine.
Examples site updated to now work with Express 4.x with full samples using hbs
Middleware preParse and handler functions
- preParse option now accepts a function allowing customization of view model object passed to view
app.use(mds.middleware({
rootDirectory: path.resolve(__dirname, 'content'),
view: 'markdown',
preParse: function(markdownFile) {
return {
title: markdownFile.meta.title,
content: markdownFile.parseContent(),
created: moment(markdownFile.created).format('L')
};
}
});
- handler function option for full control of middleware behaviour - do not specify
view
option if using this
app.use(mds.middleware({
rootDirectory: path.resolve(__dirname, 'content'),
handler: function(markdownFile, req, res, next) {
if (req.method !== 'GET') next();
// limit access
if (markdownFile.meta.draft && !req.user.isAdmin) {
next();
return;
}
var view = markdownFile.meta.view || 'markdown';
var vm = {
title: markdownFile.meta.title,
content: markdownFile.parseContent(),
created: moment(markdownFile.created).format('L')
};
res.render(view, vm);
}
});
- MarkdownServer.save() : files can be created / updated based on URI path.
- Website moved to http://lyphtec.github.io/markdown-serve, now with full API documentation
preParse option
Added preParse
option to middleware - when enabled, module will parse the Markdown content and make it available as markdownFile.parsedContent
property to view.
Example,
app.use(markdownServe.middleware({
rootDirectory: path.resolve(__dirname, '../content/markdown/'),
view: 'markdown',
preParse: true
}));