[react-markdown] Youtube embeds in Markdown (remark, rehype, react) #742
-
I created blog:
Post has content (full text) in markdown in Strapi. Next.js has component PostFull.js:
Some posts have youtube embeds, for example: Text paragraph 1
https://www.youtube.com/watch?v=PRfV5TvRjEA
Text paragraph 2 How can I show this youtube video as an iframe? I found https://github.com/sergioramos/remark-oembed, but can't understand the code. I tried:
Error in console:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Is it problem with plugin remark-oembed?
|
Beta Was this translation helpful? Give feedback.
-
There are a number of things going on here
This removes
this is coming from next/webpack not polyfilling the package
this is because
remark-oembed does not currently provide typescript typings. |
Beta Was this translation helpful? Give feedback.
There are a number of things going on here
This removes
iframes
, the schema would need to be updated to includeiframe
tags https://github.com/rehypejs/rehype-sanitize#schemathis is coming from next/webpack not polyfilling the package
dns
.this is because
react-markdown
currently expects all plugins to be syncronoushttps://github.com/remarkjs/react-markdown/blob/8ed18dafa8de638ab72a8db29f156f9fd9cf9e2e/src/react-markdown.js#L119
remark-oembed is async https://github.com/sergioramos/remark-oembed/blob/6df241fbb4ae07bcf1222d3a8ece36835273b8e1/index.js#L310
A closely related package ht…