create-react-blog icon indicating copy to clipboard operation
create-react-blog copied to clipboard

Statically define MDXComponent

Open Danissss opened this issue 5 years ago • 0 comments

In routes/posts/2019-01-06-welcome/post.js, it sets function to import document.mdx.

getContent: () => import('./document.mdx')

In routes/index.js, it reads the data from

getView: async () => {
    let { default: MDXComponent, ...other } = await getContent()
    return { MDXComponent, ...other }
}

Does MDXComponent contain all the markdown data? If I want to set the MDXComponent statically, could I do

   return Navi.route({
        title,
        getData: (req, context) => ({
          date,
          pathname,
          slug,
          previousDetails: previousPost && {
            title: previousPost.title,
            href: join(context.blogRoot, 'posts', previousSlug),
          },
          nextDetails: nextPost && {
            title: nextPost.title,
            href: join(context.blogRoot, 'posts', nextSlug),
          },
          ...meta,
        }),
        MDXComponent, // assume MDXComponent contains all the markdown data

      })

Danissss avatar Mar 09 '20 01:03 Danissss