33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { SitemapNews } from './smartsitemap.classes.sitemapnews';
|
|
import { 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<string> {
|
|
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) {
|
|
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'
|
|
});
|
|
}
|
|
}
|
|
}
|