You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: blog RSS feed generation failures with MDX posts #5664
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)
This is not a big deal because posts without HTML content are still useful in the RSS feed (behavior we had before). I'm not sure how this problem must be solved so I didn't want to introduce a new temporary API for this.
@wooorm any insight to share on how to render an MDX file (including JSX tags/imports/exports + require("./img.png") to a RSS feed HTML string?
We have something like that currently but it's obviously not ideal:
I’m doing this as a post step on the generated HTML. As in, I first generate the site. Then I take the generated HTML of recent blog posts. And turn those into a feed:
Thanks @wooorm, that was also one idea I had, and yes when we generate the blog feed the HTML files are already generated so we can definitively read them here.
I found this idea a bit hacky (likely to break due to generated filenames or HTML structure), but it can probably be good enough for now until we find better 🤪
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"?
Activity
Josh-Cena commentedon Oct 16, 2021
Regressions that make sites fail to build at all:
stylesis not defined whenimport styles from './styles.module.css';requireis not defined whenrequire('./assets/img.png').default.The missing Webpack infra is more severe than missing MDX features
[-]Bug: fix Docusaurus blog RSS feed limitations[/-][+]Bug: blog RSS feed generation failures with MDX posts[/+]slorber commentedon Oct 20, 2021
In case of MDX to HTML conversion failures, generally due to
require()calls, I added a quickfix to temporarily swallow errors here: #5753requireafter upgrading to beta 7 #5718This is not a big deal because posts without HTML content are still useful in the RSS feed (behavior we had before). I'm not sure how this problem must be solved so I didn't want to introduce a new temporary API for this.
@wooorm any insight to share on how to render an MDX file (including JSX tags/imports/exports +
require("./img.png")to a RSS feed HTML string?We have something like that currently but it's obviously not ideal:
Of all the popular MDX-based blogs, I couldn't find one where the RSS feed renders full HTML content.
wooorm commentedon Oct 21, 2021
I’m doing this as a post step on the generated HTML. As in, I first generate the site. Then I take the generated HTML of recent blog posts. And turn those into a feed:
https://github.com/mdx-js/mdx/blob/7d09ef8266ffffb089d583363e16db76e841bec1/website/post.js#L48-L110
Assuming there’s some static generation, then at some point, you already have a component for the MDX page?
slorber commentedon Oct 21, 2021
Thanks @wooorm, that was also one idea I had, and yes when we generate the blog feed the HTML files are already generated so we can definitively read them here.
I found this idea a bit hacky (likely to break due to generated filenames or HTML structure), but it can probably be good enough for now until we find better 🤪
wooorm commentedon 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"?
Josh-Cena commentedon Dec 28, 2021
Not so critical bug: #6195