queen-raae / gatsby-remark-oembed

A GatsbyJS Plugin that transforms oembed links into its corresponding embed code.
https://gatsby-remark-oembed.netlify.com/
MIT License
162 stars 25 forks source link

Fix mdx support #88

Closed Swizec closed 4 years ago

Swizec commented 4 years ago

This fixes #66

The issue was that gatsby-plugin-mdx implements onPreBootstrap, which overrides oembed's onPreBootstrap implementation. This meant that when we tried to change embed nodes, we couldn't find any providers so all nodes got ignored.

I moved onPreBootstrap code to a separate helper and call it the same way as before. This means behavior when used with Remark should be unchanged.

However, when we try to use the list of providers, we now re-fetch it and update cache if it isn't yet available in cache. This makes the plugin work with MDX.

Here's an example repository with 1 post where using gatsby-remark-oembed worked with mdx: https://github.com/Swizec/swizec-blog/tree/oembed-playground

raae commented 4 years ago

Closed in favor of #93