Challenge - 5 Problems
RSS Feed Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateWhat is the output of this Astro RSS feed generation snippet?
Given this Astro component code snippet that generates an RSS feed, what will be the content of the generated RSS XML string?
Astro
import rss from '@astrojs/rss'; export const get = () => { return rss({ title: 'My Blog', description: 'Latest posts', site: 'https://example.com', items: [ { title: 'Post 1', pubDate: new Date('2024-01-01'), link: '/post-1' }, { title: 'Post 2', pubDate: new Date('2024-01-02'), link: '/post-2' } ] }); };
Attempts:
2 left
💡 Hint
Look at how the rss function formats the items array into XML items with full links.
✗ Incorrect
The rss function generates a valid RSS 2.0 XML feed with the channel info and each item including title, full link (site + item link), and pubDate formatted in RFC 822 format.
📝 Syntax
intermediateWhich option will cause a syntax error in Astro RSS feed code?
Identify which code snippet will cause a syntax error when generating an RSS feed in Astro.
Attempts:
2 left
💡 Hint
Check the parentheses and braces carefully.
✗ Incorrect
Option C has mismatched parentheses and braces causing a syntax error.
❓ state_output
advancedWhat is the value of the 'link' field in the RSS item after running this Astro code?
Given this Astro RSS feed generation code, what is the full URL value of the 'link' field in the first item?
Astro
import rss from '@astrojs/rss'; const site = 'https://mysite.dev'; const posts = [ { title: 'Hello', slug: 'hello-world', date: '2024-05-01' } ]; export const get = () => rss({ title: 'MySite', site, items: posts.map(post => ({ title: post.title, pubDate: new Date(post.date), link: `/${post.slug}` })) });
Attempts:
2 left
💡 Hint
The rss function combines the site URL with the relative link automatically.
✗ Incorrect
The rss function prepends the site URL to the relative link path to form the full link in the RSS feed.
🔧 Debug
advancedWhy does this Astro RSS feed code throw 'TypeError: rss is not a function'?
Examine the code and select the reason for the error 'TypeError: rss is not a function'.
Astro
import { rss } from '@astrojs/rss'; export const get = () => { return rss({ title: 'Blog', site: 'https://blog.com', items: [] }); };
Attempts:
2 left
💡 Hint
Check how rss is imported from the package.
✗ Incorrect
The '@astrojs/rss' package exports rss as the default export, so using named import { rss } causes rss to be undefined.
🧠 Conceptual
expertWhich option best describes how Astro's RSS feed generation handles date formatting?
Astro's '@astrojs/rss' package requires dates in the items array. How does it handle the date formatting internally for the RSS feed?
Attempts:
2 left
💡 Hint
Think about the standard date format used in RSS feeds.
✗ Incorrect
The rss function converts Date objects to RFC 822 strings, which is the standard for pubDate in RSS 2.0 feeds.
