diff --git a/test/test.ts b/test/test.ts index a1312d7..1865c47 100644 --- a/test/test.ts +++ b/test/test.ts @@ -9,13 +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://www.theverge.com/sitemaps'); - console.log(result.sitemapindex.sitemap); + const result = await testSmartsitemap.parseSitemapUrl('https://central.eu/sitemap-news'); + console.log(result.urlset.url); }) tap.start(); diff --git a/ts/interfaces/index.ts b/ts/interfaces/index.ts index 5f0e8c8..cb9ab7d 100644 --- a/ts/interfaces/index.ts +++ b/ts/interfaces/index.ts @@ -14,4 +14,29 @@ export interface IRssItem { categories?: string[]; contentSnippet?: string; enclosure?: any; -} \ No newline at end of file +} + +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; + }; + }[]; + }; +} diff --git a/ts/smartsitemap.classes.sitemapnews.ts b/ts/smartsitemap.classes.sitemapnews.ts index e05db8d..d019ec6 100644 --- a/ts/smartsitemap.classes.sitemapnews.ts +++ b/ts/smartsitemap.classes.sitemapnews.ts @@ -44,6 +44,7 @@ export class SitemapNews { }; }[] = []; for (const itemArg of this.rssItems) { + console.log(itemArg); urls.push({ loc: itemArg.link, 'news:news': { diff --git a/ts/smartsitemap.classes.smartsitemap.ts b/ts/smartsitemap.classes.smartsitemap.ts index 843b126..9c6a98f 100644 --- a/ts/smartsitemap.classes.smartsitemap.ts +++ b/ts/smartsitemap.classes.smartsitemap.ts @@ -75,7 +75,7 @@ export class SmartSitemap { /** * parses a sitemap */ - public async parseSitemap(sitemapXmlArg: string) { + public async parseSitemap(sitemapXmlArg: string): Promise { return (new plugins.smartxml.SmartXml()).parseXmlToObject(sitemapXmlArg); } }