question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: blog RSS feed generation failures with MDX posts

See original GitHub issue

🐛 Bug Report

With https://github.com/facebook/docusaurus/pull/4330, we now render the full blog posts in the RSS feed, as HTML.

The way we currently do it is “good enough” but has several limitations:

MDX components replaced by divs

Using this MDX:

# title

import SomeCompent from "@site/src/someComponent"

<SomeCompent>Hello</SomeCompent>

Will render as:

<h1>title</h1>

<div>Hello</div>

The logic of <SomeComponent> is never evaluated.

For layout/wrapper components, it’s not a big deal as the content remains in the RSS feed, but in some cases, it can be worst.

Not having a global MDX config and giving themes the ability to “register” some MDX comps and scope can help solve this problem. Related to https://github.com/facebook/docusaurus/issues/4625

No ```mdx-code-block support

```mdx-code-block is an escape hatch we added so that external tools (like Crowdin) do not mess-up with unsupported MDX markup.

The MDX content in these code blocks must be evaluated, as if it was not a code block

No relative image path support

MD referencing co-located assets such as:

![Docusaurus beta party](./img/image_cropped.png)

will be transformed as

<img src="./img/image_cropped.png" alt="Docusaurus beta party"/>

Unfortunately, the image is not hosted at ./img/image_cropped.png in the production site due to using Webpack’s file-loader.

The real image URL in prod is /assets/images/image_cropped-2744c01b1fc0b451dbdb65a1d568fbff.png

We need a way to ensure such MD image declarations work in the RSS feed properly (ideally without changing the existing image asset URL or duplicating the asset in final site build)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
Josh-Cenacommented, Oct 16, 2021

Regressions that make sites fail to build at all:

  • styles is not defined when import styles from './styles.module.css';
  • require is not defined when require('./assets/img.png').default.

The missing Webpack infra is more severe than missing MDX features

1reaction
wooormcommented, Oct 21, 2021

You do need to have the metadata about blog posts again, and where they were rendered. And a class or ID on the body of the text. But I don’t really find it hack if it’s then very close to what instapaper or safari reader or so do, too. Alnternatively: do it when you render the content into the body. Perhaps render it twice, once with a “this is for the static website” and once with “this is for the static feed”, so components can switch and return different markup for each “media query”?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building a Next.js Blog: RSS | Ian Mitchell
js Blog: Static MDX post but it should be easy to tweak as long as you have the ability to get an array...
Read more >
Adding an RSS feed to your Next.js app - LogRocket Blog
Knowing how the post list is generated will be useful in generating RSS feeds for our blog posts. If you open the utils/mdx.js...
Read more >
How to Fix WordPress RSS Feed Errors - WPBeginner
Manually Fixing RSS Feed Errors in WordPress. The most likely reason for your RSS feeds to show error is poor formatting. This poor...
Read more >
Add an RSS Feed to Gatsby MDX Blog | The Mindless
Here's how you can do it too: The first step on the Gatsby site is to install gatsby-plugin-feed . yarn add gatsby-plugin-feed.
Read more >
Next JS build failing due to ''Export encountered errors on ...
I ran into same error few days back. few Points I would want to clarify. Build happens as per the pages and URLs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found