fix(core): update
This commit is contained in:
@ -1,7 +1,52 @@
|
||||
import * as plugins from './smartsitemap.plugins';
|
||||
|
||||
export class SitemapNews {
|
||||
public readFromRssFeed() {
|
||||
|
||||
public items: any[] = [];
|
||||
|
||||
constructor(optionsArg: {}) {}
|
||||
|
||||
public async readFromRssFeed(urlArg: string) {
|
||||
const smartfeedInstance = new plugins.smartfeed.Smartfeed();
|
||||
const parsedFeed = await smartfeedInstance.parseFeedFromUrl(urlArg);
|
||||
this.items = this.items.concat(parsedFeed.items);
|
||||
}
|
||||
|
||||
public exportSitemapXml() {
|
||||
const urls: {
|
||||
loc: string;
|
||||
'news:news': {
|
||||
'news:publication': {
|
||||
'news:name': string;
|
||||
'news:language': string;
|
||||
};
|
||||
"news:publication_date" : string;
|
||||
"news:keywords": string;
|
||||
"news:title": string;
|
||||
};
|
||||
}[] = [];
|
||||
for (const itemArg of this.items) {
|
||||
urls.push({
|
||||
loc: itemArg.link,
|
||||
"news:news": {
|
||||
"news:publication": {
|
||||
"news:language": 'en',
|
||||
"news:name": 'some name'
|
||||
},
|
||||
"news:keywords": '',
|
||||
"news:publication_date": itemArg.isoDate,
|
||||
"news:title": itemArg.title
|
||||
}
|
||||
})
|
||||
}
|
||||
const sitemapObject: any = {
|
||||
urlset: {
|
||||
'@_xmlns': 'http://www.sitemaps.org/schemas/sitemap/0.9',
|
||||
'@_xmlns:news': 'http://www.google.com/schemas/sitemap-news/0.9',
|
||||
url: urls,
|
||||
},
|
||||
};
|
||||
const smartxmlInstance = new plugins.smartxml.SmartXml();
|
||||
const sitemapString = smartxmlInstance.createXmlFromObject(sitemapObject);
|
||||
return sitemapString;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ export class SmartSitemap {
|
||||
* creates a sitemap for news
|
||||
*/
|
||||
public createSmartsitemapNews(): SitemapNews {
|
||||
const sitemapNewsInstance = new SitemapNews();
|
||||
const sitemapNewsInstance = new SitemapNews({});
|
||||
return sitemapNewsInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
// pushrocks scope
|
||||
import * as smartfeed from '@pushrocks/smartfeed';
|
||||
import * as smartxml from '@pushrocks/smartxml';
|
||||
|
||||
export {
|
||||
smartfeed,
|
||||
smartxml
|
||||
};
|
||||
|
Reference in New Issue
Block a user