fix(core): update
This commit is contained in:
parent
1296253614
commit
cd1e582f88
54
package-lock.json
generated
54
package-lock.json
generated
@ -1485,6 +1485,15 @@
|
||||
"sitemap": "^6.3.2"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartfeed": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfeed/-/smartfeed-1.0.5.tgz",
|
||||
"integrity": "sha512-3bM4IcpEgAyxxA4CKdFRUgCizo60ERMty13NeMeZq5hKDvpTdftLlawLtazvXFbHpN2uqlghCf5+eoG4+ZDUsg==",
|
||||
"requires": {
|
||||
"feed": "^4.2.1",
|
||||
"rss-parser": "^3.9.0"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartfile": {
|
||||
"version": "8.0.8",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-8.0.8.tgz",
|
||||
@ -1980,9 +1989,9 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartxml": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartxml/-/smartxml-1.0.4.tgz",
|
||||
"integrity": "sha512-lFlz7ih00md2RPRdWVcfS0cGKbKZ29g4E8dD+4EUa5o1jZ0+koF2Q4KUrngsoBXZCHUhTRKCnLjQhfx6G4AHVA==",
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartxml/-/smartxml-1.0.6.tgz",
|
||||
"integrity": "sha512-Cy//pxzdpplqE64h9/sAwvAkUBv9t3Nw9v6k2c+erXH779iOtuyGiiyWqgbRTX1wo2CRhMJqWGJx6xd2Ljq5kw==",
|
||||
"requires": {
|
||||
"fast-xml-parser": "^3.17.4"
|
||||
}
|
||||
@ -5184,6 +5193,14 @@
|
||||
"pend": "~1.2.0"
|
||||
}
|
||||
},
|
||||
"feed": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://verdaccio.lossless.one/feed/-/feed-4.2.1.tgz",
|
||||
"integrity": "sha512-l28KKcK1J/u3iq5dRDmmoB2p7dtBfACC2NqJh4dI2kFptxH0asfjmOfcxqh5Sv8suAlVa73gZJ4REY5RrafVvg==",
|
||||
"requires": {
|
||||
"xml-js": "^1.6.11"
|
||||
}
|
||||
},
|
||||
"figures": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/figures/-/figures-3.2.0.tgz",
|
||||
@ -9410,6 +9427,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"rss-parser": {
|
||||
"version": "3.9.0",
|
||||
"resolved": "https://verdaccio.lossless.one/rss-parser/-/rss-parser-3.9.0.tgz",
|
||||
"integrity": "sha512-wlRSfGrotOXuWo19Dtl2KmQt7o9i5zzCExUrxpechE0O54BAx7JD+xhWyGumPPqiJj771ndflV3sE3bTHen0HQ==",
|
||||
"requires": {
|
||||
"entities": "^2.0.3",
|
||||
"xml2js": "^0.4.19"
|
||||
},
|
||||
"dependencies": {
|
||||
"entities": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://verdaccio.lossless.one/entities/-/entities-2.1.0.tgz",
|
||||
"integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"rxjs": {
|
||||
"version": "6.6.3",
|
||||
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.6.3.tgz",
|
||||
@ -9443,8 +9476,7 @@
|
||||
"sax": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://verdaccio.lossless.one/sax/-/sax-1.2.4.tgz",
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||
},
|
||||
"saxes": {
|
||||
"version": "3.1.11",
|
||||
@ -10944,6 +10976,14 @@
|
||||
"async-limiter": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"xml-js": {
|
||||
"version": "1.6.11",
|
||||
"resolved": "https://verdaccio.lossless.one/xml-js/-/xml-js-1.6.11.tgz",
|
||||
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
|
||||
"requires": {
|
||||
"sax": "^1.2.4"
|
||||
}
|
||||
},
|
||||
"xml-name-validator": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
|
||||
@ -10954,7 +10994,6 @@
|
||||
"version": "0.4.23",
|
||||
"resolved": "https://verdaccio.lossless.one/xml2js/-/xml2js-0.4.23.tgz",
|
||||
"integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"sax": ">=0.6.0",
|
||||
"xmlbuilder": "~11.0.0"
|
||||
@ -10963,8 +11002,7 @@
|
||||
"xmlbuilder": {
|
||||
"version": "11.0.1",
|
||||
"resolved": "https://verdaccio.lossless.one/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
|
||||
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="
|
||||
},
|
||||
"xmlchars": {
|
||||
"version": "2.2.0",
|
||||
|
@ -21,7 +21,8 @@
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartxml": "^1.0.4"
|
||||
"@pushrocks/smartfeed": "^1.0.5",
|
||||
"@pushrocks/smartxml": "^1.0.6"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
|
@ -8,4 +8,11 @@ tap.test('should create an instance of Smartsitemap', async () => {
|
||||
expect(testSmartsitemap).to.be.instanceOf(smartsitemap.SmartSitemap);
|
||||
});
|
||||
|
||||
tap.test('should create a sitemap from feed', async () => {
|
||||
const sitemapNews = testSmartsitemap.createSmartsitemapNews();
|
||||
await sitemapNews.readFromRssFeed('https://www.theverge.com/rss/index.xml');
|
||||
const sitemapString = sitemapNews.exportSitemapXml();
|
||||
console.log(sitemapString);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -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
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user