-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add html
to RSS guide
#2545
Add html
to RSS guide
#2545
Conversation
✅ Deploy Preview for astro-docs-2 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a couple of larger issue questions to consider here so I can move forward with this, @bholmesdev!
I am also giving you permission to "tag out" at any time if you're uninterested in solving these issues and want to tell Team Docs to figure it out. 😅
@@ -141,35 +141,41 @@ items: import.meta.glob('./blog/*.{md,mdx}'), | |||
|
|||
The `content` key contains the full content of the post as HTML. This allows you to make your entire post content available to RSS feed readers. | |||
|
|||
:::caution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna call a flag on the play for caution here! It's not a good look to basically have Section Title then immediately CAUTION as if the thing itself is risky. If it's only our examples/explanation that requires a warning, then we fix that with writing! ;)
There are a couple of different ways we could go about doing this, but let's start by getting your gut reaction: if you were not allowed to use a caution, AND not allowed to put ANY kind of aside (note/tip) upfront like this, how/where would include this piece of information?
These examples focus on rendering Markdown contents. If you are using MDX, you will need to compile MDX contents to HTML manually. We recommend standard Markdown parsers like [Markdown-it](https://github.com/markdown-it/markdown-it) to get started, though this will not resolve JSX expressions or components. | ||
::: | ||
|
||
When using content collections, you can render post contents by calling the post's `render()` function and using the `html` property. Note the `html` property **is not present** for MDX entries. If you need to render MDX content, you can compile your MDX manually using the post's `body` property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using content collections isn't required for full-post content right? We had this before? (Since 1.6.14)
This seems like when this page was updated, it was updated to now only show an example with content collections. I think it's important to show both, especially since this our blog tutorial includes creating an RSS feed but not using collections. So while we're here and updating the example, let's find a way to re-incorporate an example that works with globbing files in src/pages/
, assuming that still works.
This was the original example for full post content. Will this (or an updated version of this) still work for projects not using collections?
import rss from '@astrojs/rss';
import sanitizeHtml from 'sanitize-html';
// Works with Markdown files only!
const postImportResult = import.meta.glob('../posts/**/*.md', { eager: true });
const posts = Object.values(postImportResult);
export const get = () => rss({
title: 'Buzz’s Blog',
description: 'A humble Astronaut’s guide to the stars',
site: import.meta.env.SITE,
items: posts.map((post) => ({
link: post.url,
title: post.frontmatter.title,
pubDate: post.frontmatter.pubDate,
content: sanitizeHtml(post.compiledContent()),
}))
});
Hi @bholmesdev - I think this idea was scrapped, and so this PR can be closed now. Please reopen if that's not the case! (There were actually two open Docs PRs associated with this, one from you and one from @bluwy , but only that one was closed alongside the Astro PR.) |
What kind of changes does this PR include?
Description
html
helper for rendering Markdown contents Return html when render markdown content astro#6097