-
Notifications
You must be signed in to change notification settings - Fork 4
Home
freezestudio edited this page Jun 15, 2018
·
6 revisions
Welcome to the fastify-markdown wiki!
Usage
register this plugin if decorate the reply methon named 'markdown' and optional param 'md'. 'md' can be a marked string or a full path markdown file name.
fastify.register(require('fastify-markdown'),/*(optional){src,data,markedOptions}*/);
now you can use the markdown
methon from reply object from route.
fastify.get('/',(req,reply)=>{
const markedString = reply.markdown(/* string or path here */);
reply.send(...)
});
if the param 'md' is a file path,it return async,so you can using fastify's async syntax.
fastify.get('/',async (req,reply)=>{
const markedString = await reply.markdown(/* string or path here */);
return markedString;
});