Issue #2022Opened May 17, 2019by shaunc8690 reactions

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)

artfMay 23, 20190 reactions

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

shaunc869May 23, 20190 reactions

This is amazing, thank you so much!

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.