fix(core): update
This commit is contained in:
parent
0f0eb2dbe8
commit
a03ceb5d8d
49
ts/index.ts
49
ts/index.ts
@ -1,47 +1,2 @@
|
||||
import { Feed, IFeedOptions } from './smartfeed.classes.feed';
|
||||
import * as plugins from './smartfeed.plugins';
|
||||
|
||||
export class Smartfeed {
|
||||
public createFeed(optionsArg: IFeedOptions) {
|
||||
const feedVersion = new Feed(optionsArg);
|
||||
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);
|
||||
return resultingFeed;
|
||||
}
|
||||
}
|
||||
export * from './smartfeed.classes.smartfeed';
|
||||
export * from './smartfeed.classes.feed';
|
||||
|
47
ts/smartfeed.classes.smartfeed.ts
Normal file
47
ts/smartfeed.classes.smartfeed.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { Feed, IFeedOptions } from './smartfeed.classes.feed';
|
||||
import * as plugins from './smartfeed.plugins';
|
||||
|
||||
export class Smartfeed {
|
||||
public createFeed(optionsArg: IFeedOptions) {
|
||||
const feedVersion = new Feed(optionsArg);
|
||||
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);
|
||||
return resultingFeed;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user