import { SitemapNews } from './smartsitemap.classes.sitemapnews'; import { IUrlInfo, SitemapWebsite } from './smartsitemap.classes.sitemapwebsite'; import * as plugins from './smartsitemap.plugins'; import * as interfaces from './interfaces'; export class SmartSitemap { constructor() {} /** * creates a sitemap for news from feedurl */ public async createSitemapNewsFromFeedUrl(feedUrlArg: string): Promise { const sitemapNewsInstance = new SitemapNews({}); await sitemapNewsInstance.readAndAddFromRssFeed(feedUrlArg); return sitemapNewsInstance.exportSitemapXml(); } /** * creates a normal sitemap from a list of urls */ public async createSitemapFromYmlString(yamlString: string): Promise { const yamlObject: interfaces.ISitemapYaml = await plugins.smartyaml.yamlStringToObject(yamlString); const sitemapWebsite = new SitemapWebsite(); for(const urlArg of yamlObject.daily) { sitemapWebsite.addUrl({ url: urlArg, timestamp: Date.now() - 10000, frequency: 'daily' }); } return sitemapWebsite.exportSitemapXml(); } /** * creates a normal sitemap from a list of urls */ public async createSitemapFromUrlInfoArray(urlInfosArg: IUrlInfo[]) { const sitemapWebsite = new SitemapWebsite(); for(const urlInfo of urlInfosArg) { sitemapWebsite.addUrl(urlInfo); } return sitemapWebsite.exportSitemapXml(); } }