fix(core): update

This commit is contained in:
2023-07-27 16:16:37 +02:00
parent 38d1d4ae0c
commit 8909652860
17 changed files with 4931 additions and 18520 deletions

View File

@@ -1,5 +1,5 @@
import { SitemapNews } from './smartsitemap.classes.sitemapnews.js';
import { IUrlInfo, SitemapWebsite } from './smartsitemap.classes.sitemapwebsite.js';
import { type IUrlInfo, SitemapWebsite } from './smartsitemap.classes.sitemapwebsite.js';
import * as plugins from './smartsitemap.plugins.js';
import * as interfaces from './interfaces/index.js';
@@ -27,7 +27,9 @@ export class SmartSitemap {
/**
* creates a sitemap for news from an array of articles
*/
public async createSitemapNewsFromArticleArray(articleArrayArg: plugins.tsclass.content.IArticle[]): Promise<string> {
public async createSitemapNewsFromArticleArray(
articleArrayArg: plugins.tsclass.content.IArticle[]
): Promise<string> {
const sitemapNewsInstance = new SitemapNews({});
await sitemapNewsInstance.readAndParseArticles(articleArrayArg);
return sitemapNewsInstance.exportSitemapXml();
@@ -37,13 +39,15 @@ export class SmartSitemap {
* creates a normal sitemap from a list of urls
*/
public async createSitemapFromYmlString(yamlString: string): Promise<string> {
const yamlObject: interfaces.ISitemapYaml = await plugins.smartyaml.yamlStringToObject(yamlString);
const yamlObject: interfaces.ISitemapYaml = await plugins.smartyaml.yamlStringToObject(
yamlString
);
const sitemapWebsite = new SitemapWebsite();
for(const urlArg of yamlObject.daily) {
for (const urlArg of yamlObject.daily) {
sitemapWebsite.addUrl({
url: urlArg,
timestamp: Date.now() - 10000,
frequency: 'daily'
frequency: 'daily',
});
}
return sitemapWebsite.exportSitemapXml();
@@ -54,7 +58,7 @@ export class SmartSitemap {
*/
public async createSitemapFromUrlInfoArray(urlInfosArg: IUrlInfo[]) {
const sitemapWebsite = new SitemapWebsite();
for(const urlInfo of urlInfosArg) {
for (const urlInfo of urlInfosArg) {
sitemapWebsite.addUrl(urlInfo);
}
return sitemapWebsite.exportSitemapXml();
@@ -64,9 +68,11 @@ export class SmartSitemap {
* parses a sitemap url
*/
public async parseSitemapUrl(urlArg: string) {
const sitemapXml = await (await (new plugins.webrequest.WebRequest()).request(urlArg, {
method: 'GET'
})).text();
const sitemapXml = await (
await new plugins.webrequest.WebRequest().request(urlArg, {
method: 'GET',
})
).text();
const parsedSitemap = await this.parseSitemap(sitemapXml);
return parsedSitemap;
@@ -76,6 +82,6 @@ export class SmartSitemap {
* parses a sitemap
*/
public async parseSitemap(sitemapXmlArg: string): Promise<interfaces.IParsedSiteMap> {
return (new plugins.smartxml.SmartXml()).parseXmlToObject(sitemapXmlArg);
return new plugins.smartxml.SmartXml().parseXmlToObject(sitemapXmlArg);
}
}