2 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
6 changed files with 33 additions and 7 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartsitemap", "name": "@pushrocks/smartsitemap",
"version": "1.0.12", "version": "1.0.13",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartsitemap", "name": "@pushrocks/smartsitemap",
"version": "1.0.12", "version": "1.0.13",
"private": false, "private": false,
"description": "a sitemap module", "description": "a sitemap module",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

@ -9,13 +9,13 @@ tap.test('should create an instance of Smartsitemap', async () => {
}); });
tap.test('should create a sitemap from feed', 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); console.log(sitemapString);
}); });
tap.test('should parse a sitemap', async () => { tap.test('should parse a sitemap', async () => {
const result = await testSmartsitemap.parseSitemapUrl('https://www.theverge.com/sitemaps'); const result = await testSmartsitemap.parseSitemapUrl('https://central.eu/sitemap-news');
console.log(result.sitemapindex.sitemap); console.log(result.urlset.url);
}) })
tap.start(); tap.start();

View File

@ -14,4 +14,29 @@ export interface IRssItem {
categories?: string[]; categories?: string[];
contentSnippet?: string; contentSnippet?: string;
enclosure?: any; 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) { for (const itemArg of this.rssItems) {
console.log(itemArg);
urls.push({ urls.push({
loc: itemArg.link, loc: itemArg.link,
'news:news': { 'news:news': {

View File

@ -75,7 +75,7 @@ export class SmartSitemap {
/** /**
* parses a sitemap * parses a sitemap
*/ */
public async parseSitemap(sitemapXmlArg: string) { public async parseSitemap(sitemapXmlArg: string): Promise<interfaces.IParsedSiteMap> {
return (new plugins.smartxml.SmartXml()).parseXmlToObject(sitemapXmlArg); return (new plugins.smartxml.SmartXml()).parseXmlToObject(sitemapXmlArg);
} }
} }