Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Updated with-mdx-remote dynamic components example (vercel#25366)
Browse files Browse the repository at this point in the history
- Fixed the missing prop `components` to `<MDXRemote/>`.
- Added a `defaultComponents` and `source` mdx to provide more clarity on the example.

## Documentation / Examples

- [x] Make sure the linting passes
  • Loading branch information
payapula authored Jun 2, 2021
1 parent ea5118f commit 7b7e867
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions examples/with-mdx-remote/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ For example, here's how you can change `getStaticProps` to pass a list of compon

```js
import dynamic from 'next/dynamic'
import Test from '../components/test'

const SomeHeavyComponent = dynamic(() => import('SomeHeavyComponent'))

// ...
const defaultComponents = { Test }

export function SomePage({ mdxSource, componentNames }) {
const components = {
...defaultComponents,
Expand All @@ -46,10 +48,17 @@ export function SomePage({ mdxSource, componentNames }) {
: null,
}

return <MDXRemote {...mdxSource} />
return <MDXRemote {...mdxSource} components={components} />
}

export async function getStaticProps() {
const source = `---
title: Conditional custom components
---
Some **mdx** text, with a default component <Test name={title}/> and a Heavy component <SomeHeavyComponent />
`

const { content, data } = matter(source)

const componentNames = [
Expand Down

0 comments on commit 7b7e867

Please sign in to comment.