Does gatsby-remark-emojis work with gatsby-plugin-mdx?
ibqn opened this issue · 6 comments
Hi, I am struggling to get this plugin working with gatsby-plugin-mdx
.
Is this option actually supported?
const gatsbyRemarkPlugins = [
{
resolve: `gatsby-remark-katex`,
options: { macros, throwOnError: false },
},
`gatsby-remark-images`,
{
resolve: `gatsby-remark-emojis`,
options: {
// Deactivate the plugin globally (default: true)
active: true,
// Add a custom css class
class: "emoji-icon",
// Select the size (available size: 16, 24, 32, 64)
size: 64,
// Add custom styles
styles: {
display: "inline",
margin: "0",
"margin-top": "1px",
position: "relative",
top: "5px",
width: "25px",
},
},
},
]
...
module.exports = {
...
plugins: [
...
{
resolve: `gatsby-plugin-mdx`,
options: {
defaultLayouts: {
default: require.resolve(`./src/components/layout.jsx`),
},
gatsbyRemarkPlugins,
},
},
...
],
}
Thanks.
Hi @ibqn, thanks for submitting this issue 🙏. I haven't used the gatsby-plugin-mdx
plugin, but it might be the case that the standard Gatsby lifecycle rendering methods differ and that gatsby-remark-emojis
isn't actually being called.
Did you get any error logs?
[Off-topic]: What's the benefit of using .mdx
compared to standard code blocks in Markdown?
Hi there,
I have the same problem. I'm also using mdx
, and can't get this plugin to work. Is there any way to fix it?
@iloveip, my solution is to use remark-emoji
plugin instead directly.
const gatsbyRemarkPlugins = [
...
]
module.exports = {
...
plugins: [
...
{
resolve: `gatsby-plugin-mdx`,
options: {
...
gatsbyRemarkPlugins,
remarkPlugins: [require(`remark-emoji`)],
},
},
],
...
}
Here is the reference to the gatsby docs. https://www.gatsbyjs.org/docs/mdx/plugins/#remark-plugins
@matchilling
to your off-topic question: The benefit for me is that I can include react components additionally to the markdown blocks, which gives me an a rich range of possibilities.
For example:
# Header
body text
<ContanctMe />
## why shout you use this option to contact me
or what so ever
Thus, you can use mdx to create your some pages, in addition to blog posts.
@iloveip, my solution is to use
remark-emoji
plugin instead directly.const gatsbyRemarkPlugins = [ ... ] module.exports = { ... plugins: [ ... { resolve: `gatsby-plugin-mdx`, options: { ... gatsbyRemarkPlugins, remarkPlugins: [require(`remark-emoji`)], }, }, ], ... }Here is the reference to the gatsby docs. https://www.gatsbyjs.org/docs/mdx/plugins/#remark-plugins
But that solution produce another issue about ESM support and so this leads to adding fixes to the fixes.
Actually just gatsby-remark-emojis doesn't work with gatsby-plugin-mdx.
Hope a reliable solution will be found :)