localgreenchain/components/media.tsx
2023-08-09 21:34:23 +00:00

25 lines
434 B
TypeScript

import { DrupalMedia } from "next-drupal"
import { MediaImage } from "components/media--image"
const mediaTypes = {
"media--image": MediaImage,
}
export interface MediaProps {
media: DrupalMedia
}
export function Media({ media, ...props }: MediaProps) {
if (!media) {
return null
}
const Component = mediaTypes[media.type]
if (!Component) {
return null
}
return <Component media={media} {...props} />
}