adding-an-rss-feed suggestion of adding encodeURI() to the code example and adding Feed Validation into the doc #31498
-
I followed the How-To guide Adding an RSS Feed to build my own rss.xml, then I found the RSS feed cannot trigger an RSS subscription of Mailchimp. I spent some time to solve the problem that is the slugs of my posts are mandarin making the rss.xml unable to pass the validate test of W3C feed validation service. The URIs of the posts have to be encoded in advanced so that the rss.xml can pass the test. I think adding some content into this doc can benefit all the developers who use slugs containing non-ascii letters by saving their time. I suggest the adding-an-rss-feed.md can add two things into it. First thing is to add a paragraph between "By default,..." and "To see...", which can be like this: If your blog has none-English link, you may need to encode URI in advance. You can use the function serialize: ({ query: { site, allMarkdownRemark } }) => {
return allMarkdownRemark.edges.map(edge => {
/* highlight-end */
return Object.assign({}, edge.node.frontmatter, {
description: edge.node.excerpt,
date: edge.node.frontmatter.date,
// highlight-next-line
url: encodeURI(site.siteMetadata.siteUrl + edge.node.fields.slug),
guid: site.siteMetadata.siteUrl + edge.node.fields.slug,
custom_elements: [{ "content:encoded": edge.node.html }],
})
})
}, Second thing is to add a link of Feed Validation to the end of the paragraph of "To see...", such as: To see your feed in action, run This is my first issue at Github, if I did something wrong, pleas don't hesitate to tell me, thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi! That sounds like a good addition to the doc! We'd love to review a PR for this :) |
Beta Was this translation helpful? Give feedback.
Hi!
That sounds like a good addition to the doc! We'd love to review a PR for this :)
https://www.gatsbyjs.com/contributing/docs-contributions/