X Tutup
The Wayback Machine - https://web.archive.org/web/20210626171917/https://github.com/facebook/docusaurus/issues/3719
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2: Non truncated blog article in feeds #3719

Open
MatanBobi opened this issue Nov 10, 2020 · 15 comments · May be fixed by #4330
Open

V2: Non truncated blog article in feeds #3719

MatanBobi opened this issue Nov 10, 2020 · 15 comments · May be fixed by #4330

Comments

@MatanBobi
Copy link
Contributor

@MatanBobi MatanBobi commented Nov 10, 2020

🚀 Feature

When working with the blog feed, in testing-library's, we would like a way to contain the full article and not just a truncated version of it within the feed since we don't really care about retention or something like that.

Motivation

Following this PR in testing-library, we think that having a way to send a non truncated version of an article can be helpful for people that just want to spread the word and don't care about traffic to their site rather than just spread updates.

Pitch

I believe we can add this by adding another config to the blog feed options, I'd be glad to help and create a PR for this one if you find it suitable.

Thanks for your hard work and help!

@MatanBobi MatanBobi changed the title Non truncated blog feeds Non truncated blog article in feeds Nov 10, 2020
@MatanBobi MatanBobi changed the title Non truncated blog article in feeds V2: Non truncated blog article in feeds Nov 10, 2020
@nickmccurdy
Copy link
Contributor

@nickmccurdy nickmccurdy commented Nov 10, 2020

Adding to the rationale here, I would expect most Docusaurus sites to be for community projects that don't need users to visit blog posts for monetization via advertisements or conversions. I think leaving blog posts non-truncated by default and adding an option for the old behavior (if encouraging site traffic or reducing feed size is necessary) would be even better.

@nickmccurdy
Copy link
Contributor

@nickmccurdy nickmccurdy commented Nov 10, 2020

Also, this should be relevant to both V1 and V2. If approved, perhaps it should be backported from 2 to 1 or merged into 2 after 1.

@slorber
Copy link
Collaborator

@slorber slorber commented Nov 12, 2020

Ok for an option to have non-truncated feeds.

I don't know much about RSS feeds and best practices regarding monetization/conversions, but if you can back up your claims by some authority link that explains why it's better to have non-truncated articles in feeds, we can make this the default.

@slorber
Copy link
Collaborator

@slorber slorber commented Nov 12, 2020

Also, this should be relevant to both V1 and V2. If approved, perhaps it should be backported from 2 to 1 or merged into 2 after 1.

v1 is in low maintenance mode, it's not very important to backport this feature now, we'll encourage people to adopt v2 instead.

@MatanBobi
Copy link
Contributor Author

@MatanBobi MatanBobi commented Nov 12, 2020

I can take this one if it's ok :)

@MatanBobi
Copy link
Contributor Author

@MatanBobi MatanBobi commented Nov 15, 2020

Ok for an option to have non-truncated feeds.

I don't know much about RSS feeds and best practices regarding monetization/conversions, but if you can back up your claims by some authority link that explains why it's better to have non-truncated articles in feeds, we can make this the default.

Taken from the RSS 2.0 Spec:

A channel may contain any number of <item>s. An item may represent a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed), and the link and title may be omitted. All elements of an item are optional, however at least one of title or description must be present.

I think we should keep the title and URL even if the description contains the whole item.
Any thoughts? I've already started working on this btw.

@nickmccurdy
Copy link
Contributor

@nickmccurdy nickmccurdy commented Nov 16, 2020

If I remember correctly the generated description didn't seem to include the title and URL

@MatanBobi
Copy link
Contributor Author

@MatanBobi MatanBobi commented Nov 25, 2020

@slorber I've implemented this and I did get the full post in the description but it was plain markdown and nothing rendered it.. I saw that in the classic-theme you use MDXProvider to render the MDX.. Any ideas what we can do here for the feeds?
Thanks!

@slorber
Copy link
Collaborator

@slorber slorber commented Nov 25, 2020

I see

The thing is, a user might be able to add mdx interactive components in the blog post. In such case, what should be the behavior of such feed? The feed reader won't be able to render the React component, but we can still render such component and get it as a static HTML string (it's just it won't be interactive anymore).

You should likely call ReactDOM.renderToString to generate the feed as HTML

MDXProvider only permits to replace default HTML elements with custom implementations, that does not seem 100% mandatory, but may be helpful to improve the default renderToString if not good enough. Unfortunately due to the modular architecture, the blog plugin does not know anything about the classic theme, and can't reuse this MDX provider. Maybe we need it for proper code block highlighting?

The question is: how do we transform markdown to a JSX tree on the server, so that we can feed renderToString with it?

The MDX apis I know compile markdown to React component source code, not a JSX directly.
We generally write this source code to disk, and require it like regular source code. Wonder if we can avoid this step that seems a bit useless in such case.

@slorber
Copy link
Collaborator

@slorber slorber commented Nov 25, 2020

Looks like mdx/runtime is what we are looking for: https://mdxjs.com/advanced/runtime

Something like this may work

import React from "react";
import ReactDOMServer from 'react-dom/server';
import MDX from "@mdx-js/runtime";

async function mdxToHtml(sourceFilePath) {
  const mdxString = await fs.readFile(sourceFilePath);
  return ReactDOMServer.renderToString(<MDX>{mdxString}</MDX>);
}
@slorber slorber linked a pull request that will close this issue Mar 3, 2021
@slorber
Copy link
Collaborator

@slorber slorber commented Mar 3, 2021

There's a pending PR here: #4330

Let me know if the implementation looks good to you, but to me it does not because it assume the blog post content is a regular string

@MatanBobi
Copy link
Contributor Author

@MatanBobi MatanBobi commented Mar 4, 2021

There's a pending PR here: #4330

Let me know if the implementation looks good to you, but to me it does not because it assume the blog post content is a regular string

Hi @slorber!
Sorry, I didn't get a chance to solve this one and I have a WIP draft on my local machine..
Regarding what you wrote, I strongly agree. I'll try to add that functionality soon if this won't be solved in that PR already.

@moonrailgun
Copy link
Contributor

@moonrailgun moonrailgun commented Mar 6, 2021

In my pr #4330, I already change render from plain text to Full Markdown support, but without customize component.

and i dont think its a good idea for add config to choose whether show full content for blog. Its not a content website, you know.

For feed of docusaurus, I wanna know is any other suggest about that? I am glad with someone still use rss, and hope to improve user experience in docusaurus

@MatanBobi
Copy link
Contributor Author

@MatanBobi MatanBobi commented Mar 7, 2021

and i dont think its a good idea for add config to choose whether show full content for blog. Its not a content website, you know.

@moonrailgun
Actually, I do think it should be a config, one of the purposes of RSS feeds is to attract people to your site and gain visitors, not all use cases should show all content.

If you're working on that, I'll delete my draft, but for further work you do on OSS, it's generally a good idea to ask in the issue if someone is still working on a feature :)

@moonrailgun
Copy link
Contributor

@moonrailgun moonrailgun commented Mar 7, 2021

and i dont think its a good idea for add config to choose whether show full content for blog. Its not a content website, you know.

@moonrailgun
Actually, I do think it should be a config, one of the purposes of RSS feeds is to attract people to your site and gain visitors, not all use cases should show all content.

If you're working on that, I'll delete my draft, but for further work you do on OSS, it's generally a good idea to ask in the issue if someone is still working on a feature :)

I am soooo sorry for that because i have not found your issue before.

and for config, maybe your can add a config above my work? Also i dont think its right, but more customize way is not a bad work, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
X Tutup