fix(core): update

This commit is contained in:
2020-10-31 11:38:41 +00:00
parent 12304dca17
commit 2613d20cb8
4 changed files with 69 additions and 52 deletions

View File

@ -7,12 +7,38 @@ export class Smartfeed {
return feedVersion;
}
/**
* creates a feed from a standardized article object (@tsclass/tsclass).content.IArticle
*/
public async createFeedFromArticleArray(optionsArg: IFeedOptions, articleArray: plugins.tsclass.content.IArticle[]): Promise<string> {
const feed = this.createFeed(optionsArg);
for (const article of articleArray) {
feed.addItem({
authorName: `${article.author.firstName} ${article.author.surName}`,
timestamp: article.timestamp,
imageUrl: article.featuredImageUrl,
title: article.title,
url: article.url
});
}
const feedXmlString = feed.exportRssFeedString();
return feedXmlString;
}
/**
* allows the parsing of a rss feed string
* @param rssFeedString
*/
public async parseFeedFromString(rssFeedString: string) {
const parser = new plugins.rssParser();
const resultingFeed = await parser.parseString(rssFeedString);
return resultingFeed;
}
/**
* allows the parsing of a feed from urls
* @param urlArg
*/
public async parseFeedFromUrl(urlArg: string) {
const parser = new plugins.rssParser();
const resultingFeed = await parser.parseURL(urlArg);

View File

@ -1,3 +1,10 @@
// tsclass scope
import * as tsclass from '@tsclass/tsclass';
export {
tsclass
};
// third party scope
import rssParser from 'rss-parser';
import * as feed from 'feed';