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

feat(blog): add feed XSLT options to render beautiful RSS and Atom feeds #9252

Merged
merged 41 commits into from
Aug 2, 2024

Conversation

Xebec19
Copy link
Contributor

@Xebec19 Xebec19 commented Aug 23, 2023

Motivation

Adding XSLT / CSS support for the blog feeds permits to style them instead of printing XML markup:

CleanShot 2024-08-02 at 18 19 46

This PR adds a new feedOptions.xslt attribute that permits to:

  • conveniently turn on (true} default XSLT/CSS styling using our built-in .xsl/.css
    files
  • provide your own .xsl / .css files for custom styling
const blog = {
  feedOptions: {
    xslt: true, // Easily turn the option on
  }
};

const blog = {
  feedOptions: {
    xslt: {
      rss: "custom-rss.xsl", // use custom .xsl for the RSS feed 
      atom: true, // use the built-in .xsl for the Atom feed
    },
  }
};

Test Plan

CI / unit test / argos / dogfood

Test links

Before:

After (Default xslt):

After (Custom xslt)

Related issues/PRs

Fix #9197

Related links

Feature inspired by these resources:

Examples of other styled RSS feeds:

@facebook-github-bot
Copy link
Contributor

Hi @Xebec19!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify
Copy link

netlify bot commented Aug 23, 2023

[V2]

Name Link
🔨 Latest commit 3e55314
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/66ad0c6ef7edf40008559f69
😎 Deploy Preview https://deploy-preview-9252--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link

github-actions bot commented Aug 23, 2023

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🟠 60 🟢 98 🟢 96 🟢 100 Report
/docs/installation 🟠 51 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 75 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 67 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🔴 49 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 69 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 74 🟢 100 🟢 100 🟠 86 Report

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 23, 2023
@slorber slorber added Argos Add this label to run UI visual regression tests. See argos.yml GH action. pr: new feature This PR adds a new API or behavior. labels Aug 24, 2023
@argos-ci
Copy link

argos-ci bot commented Aug 24, 2023

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ Reference build (Review) 2 changed Aug 2, 2024, 4:49 PM

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

That looks like a good start but is not enough to be merged for a few reasons.


In case it wasn't clear: the goal is not to add XSLT just for our own website, but to build it as a feature for any Docusaurus site to have by default.

It needs to be modular and it needs to work well out of the box on any Docusaurus site, without conflicting with existing user static assets. My suggestion would be to output the xslt/css next to the feeds, under /blog/ for example, so that it is namespaced and we can use 2 blogs with different CSS/XSLT files.


The Atom feed is broken, see:

CleanShot 2023-08-24 at 17 11 51@2x

Also I don't think it looks super great as is. My suggestion would be to steal/adapt XSLT/CSS from what https://darekkay.com/blog/rss-styling/ is using. We'll improve from there.

packages/docusaurus-plugin-content-blog/src/feed.ts Outdated Show resolved Hide resolved
website/static/rss.xslt Outdated Show resolved Hide resolved
website/static/styles.css Outdated Show resolved Hide resolved
@slorber slorber marked this pull request as draft August 24, 2023 15:11
@Xebec19
Copy link
Contributor Author

Xebec19 commented Aug 24, 2023

OK I will do the requested changes

@Xebec19 Xebec19 requested a review from slorber September 3, 2023 08:12
@Xebec19 Xebec19 marked this pull request as ready for review September 8, 2023 03:44
@slorber slorber added the apprentice Issues that are good candidates to be handled by a Docusaurus apprentice / trainee label Sep 25, 2023
@OzakIOne
Copy link
Collaborator

During the refactor of my review I've thought about the customization.

Original files are in the plugin content blog (I don't think its the right place though it works)

  • in each build docusaurus website there will be those original files even if the feature is not used (no big deal but still)
  • the customization is done in the static directory which works but i guess would be better if it's in blog directory (like authors.yml)
  • it might be possible to avoid code duplication in the addXslt function, and just call the function for each feed in the switch case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apprentice Issues that are good candidates to be handled by a Docusaurus apprentice / trainee Argos Add this label to run UI visual regression tests. See argos.yml GH action. CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blog feeds render nicely by default (XSLT stylesheet)
4 participants