rsnext/examples/cms-contentful/components/rich-text-asset.js
David Fateh 3861e4b8ec
Adding Asset Component for Rich Text Renderer (#32503)
This PR accomplishes 2 things:

1. You can now add images to the rich text post of the example and see those images show up in the app. This is a good jumping off point for people who are learning how to customize the rich text renderers by adding custom components to the mapper.
2. Updating the README pictures to have a more up-to-date UI in the screenshots.

## Feature
- [x] Documentation added

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-01-07 22:51:39 +00:00

11 lines
266 B
JavaScript

import Image from 'next/image'
export default function RichTextAsset({ id, assets }) {
const asset = assets?.find((asset) => asset.sys.id === id)
if (asset?.url) {
return <Image src={asset.url} layout="fill" alt={asset.description} />
}
return null
}