4 Commits

Author SHA1 Message Date
aabb8265cd 1.0.13 2021-01-03 02:48:45 +00:00
b8befa85fa fix(core): update 2021-01-03 02:48:45 +00:00
114cd1900b 1.0.12 2021-01-03 02:08:01 +00:00
17d8cd6585 fix(core): update 2021-01-03 02:08:00 +00:00
7 changed files with 61 additions and 13 deletions

13
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartsitemap",
"version": "1.0.11",
"version": "1.0.13",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1566,7 +1566,6 @@
"version": "4.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-4.0.5.tgz",
"integrity": "sha512-i4kBjZSbs1t8swcAPEdPkDJHci2higzvMIkNUKTgXWrcxUFMuOis/B5huUnnIqg/Td8R+mAdf/B/CMfgjABTlg==",
"dev": true,
"requires": {
"@types/buffer-json": "^2.0.0",
"@types/fast-json-stable-stringify": "^2.0.0",
@ -2033,7 +2032,6 @@
"version": "2.0.13",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fwebrequest/-/webrequest-2.0.13.tgz",
"integrity": "sha512-FNRthRBrBmc3Eu+NRkVrPudbmWMphph/Y15feHo7tUj7Y4MhP0uSy2/95vM3b5LcXQldOEH3GA9SB7VYJ1+VPw==",
"dev": true,
"requires": {
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartenv": "^4.0.15",
@ -2156,8 +2154,7 @@
"@types/buffer-json": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/@types%2fbuffer-json/-/buffer-json-2.0.0.tgz",
"integrity": "sha512-nFKOrY93Tvv5Tobws+YbkGlPOJsn1nVpZah3BlSyQ4EniFm97KLvSr54tZ5xQp8mlf/XxbYwskNCYQB9EdrPlQ==",
"dev": true
"integrity": "sha512-nFKOrY93Tvv5Tobws+YbkGlPOJsn1nVpZah3BlSyQ4EniFm97KLvSr54tZ5xQp8mlf/XxbYwskNCYQB9EdrPlQ=="
},
"@types/chai": {
"version": "4.2.14",
@ -3218,8 +3215,7 @@
"buffer-json": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/buffer-json/-/buffer-json-2.0.0.tgz",
"integrity": "sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw==",
"dev": true
"integrity": "sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw=="
},
"buffer-xor": {
"version": "1.0.3",
@ -7526,8 +7522,7 @@
"node-fetch": {
"version": "2.6.1",
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"dev": true
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"node-forge": {
"version": "0.7.6",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartsitemap",
"version": "1.0.11",
"version": "1.0.13",
"private": false,
"description": "a sitemap module",
"main": "dist_ts/index.js",
@ -25,6 +25,7 @@
"@pushrocks/smartfeed": "^1.0.5",
"@pushrocks/smartxml": "^1.0.6",
"@pushrocks/smartyaml": "^2.0.5",
"@pushrocks/webrequest": "^2.0.13",
"@tsclass/tsclass": "^3.0.25"
},
"browserslist": [

View File

@ -9,8 +9,13 @@ tap.test('should create an instance of Smartsitemap', async () => {
});
tap.test('should create a sitemap from feed', async () => {
const sitemapString = await testSmartsitemap.createSitemapNewsFromFeedUrl('https://www.theverge.com/rss/index.xml');
const sitemapString = await testSmartsitemap.createSitemapNewsFromFeedUrl('https://central.eu/feed');
console.log(sitemapString);
});
tap.test('should parse a sitemap', async () => {
const result = await testSmartsitemap.parseSitemapUrl('https://central.eu/sitemap-news');
console.log(result.urlset.url);
})
tap.start();

View File

@ -15,3 +15,28 @@ export interface IRssItem {
contentSnippet?: string;
enclosure?: any;
}
export interface IParsedSiteMap {
urlset: {
url:
| {
loc: string;
lastmod: string;
changefreq: string;
}
| {
loc: string;
lastmod: string;
changefreq: string;
}[]
| {
loc: string;
'news:news': {
'news:publication': [];
'news:keywords': string;
'news:publication_date': string;
'news:title': string;
};
}[];
};
}

View File

@ -44,6 +44,7 @@ export class SitemapNews {
};
}[] = [];
for (const itemArg of this.rssItems) {
console.log(itemArg);
urls.push({
loc: itemArg.link,
'news:news': {

View File

@ -59,4 +59,23 @@ export class SmartSitemap {
}
return sitemapWebsite.exportSitemapXml();
}
/**
* parses a sitemap url
*/
public async parseSitemapUrl(urlArg: string) {
const sitemapXml = await (await (new plugins.webrequest.WebRequest()).request(urlArg, {
method: 'GET'
})).text();
const parsedSitemap = await this.parseSitemap(sitemapXml);
return parsedSitemap;
}
/**
* parses a sitemap
*/
public async parseSitemap(sitemapXmlArg: string): Promise<interfaces.IParsedSiteMap> {
return (new plugins.smartxml.SmartXml()).parseXmlToObject(sitemapXmlArg);
}
}

View File

@ -3,12 +3,14 @@ import * as smartcache from '@pushrocks/smartcache';
import * as smartfeed from '@pushrocks/smartfeed';
import * as smartxml from '@pushrocks/smartxml';
import * as smartyaml from '@pushrocks/smartyaml';
import * as webrequest from '@pushrocks/webrequest';
export {
smartcache,
smartfeed,
smartxml,
smartyaml
smartyaml,
webrequest
};
// tsclass