RSS Feed
Question
Hi!
I have a question, I searched but couldn't find an answer, is there a component that pulls in an RSS feed and formats it on the page. MailChimp and Campaign Monitor do this, here is an example feed: http://www.homecaredaily.com/feed/ I realize some of this is done server side, but just looking to see if anyone has tackled this before or some guidance on this feature. Thanks!
Answers (2)
Hi Shaun, I think it should not be that complex to implement if you read how Components and Traits work. It should be something like this (take it as a pseudo-code):
editor.DomComponents.addType('rss-feed', {
model: {
defaults: {
total: 10, // eg. how many feeds to render
feed: 'https://.../feed1', // default feeds to render
traits: [
{
type: 'select',
name: 'feed',
changeProp: 1,
options: [ 'https://.../feed1', 'https://.../feed2' ],
}, {
type: 'number',
name: 'total',
changeProp: 1,
}
]
},
init() {
this.listenTo(this, 'change:feed change:total', this.refreshContent);
this.refreshContent();
},
async refreshContent() {
const { feed, total } = this.attributes;
const parser = new RSSParser(); // eg. using https://www.npmjs.com/package/rss-parser
const feeds = await parser.parseURL(feed);
const result = feeds.items.slice(0, total).map(item => `<div>
<h1>${item.title}</h1>
<p>${item.text}</p>
<div>`);
this.components(result.join(''));
}
}
});
then add a block to let users drag it in the canvas
This is amazing, thank you so much!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1135
[Question] Two html tags as one (link/button)
Is it possible to have two elements (div and lnik) and consider as a single? For example: there is the my following link block: <div class=...
Issue #3285
[Question]: Doctype in the canvas iframe
Hi. This question has already been asked twice (here and here) but has never got an answer. Is there a way to add <!DOCTYPE html> as the be...
Issue #680
DOM/Component buginess when editing Classes/Settings
Encountered this while developing a plugin. I've reproduced it in the official demo via Browserstack on a different OS and browser, so I'm...
Issue #1053
[Question] Flag for preservation of unused styles
Hey @artf, is there any flag available to leave the unused styles? Referencing to you provided answer here. Thanks in advance and have a gr...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.