Closed balupton closed 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.
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!
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.