Skip to content

Instantly share code, notes, and snippets.

@MoOx
Created September 29, 2016 15:06
Show Gist options
  • Save MoOx/e086b2bd9e31bf6d2e95dc24b51735a9 to your computer and use it in GitHub Desktop.
Save MoOx/e086b2bd9e31bf6d2e95dc24b51735a9 to your computer and use it in GitHub Desktop.
import remark from "remark"
import slug from "remark-slug"
import autoLinkHeadings from "remark-autolink-headings"
import highlight from "remark-highlight.js"
import toc from "remark-toc"
import html from "remark-html"
function mdify(text) {
return remark()
// https://github.com/wooorm/remark-slug
.use(slug)
// https://github.com/wooorm/remark-html
.use(html, { entities: "escape" })
// https://github.com/ben-eb/remark-highlight.js
.use(highlight)
// https://github.com/wooorm/remark-toc
.use(toc)
// render
.process(text, {
commonmark: true,
})
.toString()
}
export default ({ result }) => {
return {
...result,
body: mdify(result.body),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment