Creating an RSS feed in restdb.io

by Knut Martin Tornes - July 25 2016

In restdb.io you can easily serve many different content types. Creating an RSS feed is done simply by creating a restdb.io Page, set up the data context/query, write the necessary XML markup and finally set the content type to text/xml.

The RSS feed we have created for this blog does not have any "View Source" like the other pages, but you can see it here.
{{#context}}
{
    "posts": {
        "collection": "blogposts",
        "query": {"published":true},
        "hints": {"$orderby":{"date":-1}}
    }
}
{{/context}}
<!--?xml version="1.0" encoding="UTF-8" ?-->
<rss version="2.0">
<channel>
 <title>restdb.site blog postings</title>
 <description>This RSS feed was created with restdb.io Pages</description>
 <pubdate>{{moment posts.0._updated 'ddd, DD MMM YYYY HH:mm:ss'}}</pubdate>
 <link>https://restdb.site
 <ttl>1800</ttl>
 {{#each posts}}
 <item>
   <title>{{title}}</title>
   <description><!--[CDATA[{{{teaser}}}]]--></description>
   <link><!--[CDATA[https://restdb.site/blog/{{_id}}]]-->
   <pubdate>{{moment date utc=true add="hours" value="4" format="ddd, DD MMM YYYY HH:mm:ss"}}</pubdate>
   <img>https://websitedemo-4db9.restdb.io/media/{{image.[0]}}
 </item>
 {{/each}}
</channel>
</rss>

Back

View Source