mdx-js / mdx

Markdown for the component era
https://mdxjs.com
MIT License
17.43k stars 1.14k forks source link

No documentation for async methods #387

Closed balupton closed 5 years ago

balupton commented 5 years ago

Seems the only API that is documented for using MDX directly is the sync API at https://mdxjs.com/advanced/sync-api

However it refers to an async API, however there is no documentation for any async API.

It would be nice for the documentation for direct use to be more elaborate.

balupton commented 5 years ago

At the end of the day, all I am after is something that returns all the exports of the mdx file.

Such that:

export const meta = {title: 'sup'}
# markdown

Can be used like so:

// sync API
const data = require('some-mdx-method')('the-content-above')
const meta = data.meta
const Component = data.default
const renderedHTMLString = require('some-other-method')(Component, {some: 'props'})

// async API
async function main () {
  const mdx = require('some-mdx-method')
  const data = await mdx('the-content-above')
  const meta = data.meta
  const Component = data.default
  const render = require('some-other-method')
  const renderedHTMLString = await render(Component, {some: 'props'})
}
main()

This would make it a lot easier to build blogs, that have RSS feeds, and blog listing pages.

johno commented 5 years ago

Thanks for opening up this issue! I've added more detailed docs to the v1 branch (since the output of the JSX will be changing) that can be found at: https://v1-alpha.mdxjs.com/advanced/

If you think something is missing or it could be improved please let us know!