Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
35680b135d | |||
3170da0303 | |||
8a78cc6831 | |||
911c680452 | |||
0a3768a088 | |||
7ae31b4ee0 | |||
ac3d9aeb2d | |||
c312622fb1 | |||
89829b84f4 | |||
2b2111b2f1 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartsitemap",
|
"name": "@pushrocks/smartsitemap",
|
||||||
"version": "1.0.5",
|
"version": "1.0.10",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartsitemap",
|
"name": "@pushrocks/smartsitemap",
|
||||||
"version": "1.0.5",
|
"version": "1.0.10",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a sitemap module",
|
"description": "a sitemap module",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
daily:
|
daily:
|
||||||
- central.eu/
|
- central.eu/
|
||||||
- central.eu/privacy
|
- central.eu/privacy
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export * from './smartsitemap.classes.smartsitemap';
|
export * from './smartsitemap.classes.smartsitemap';
|
||||||
export * from './smartsitemap.classes.sitemapnews';
|
export * from './smartsitemap.classes.sitemapnews';
|
||||||
|
export * from './smartsitemap.classes.sitemapwebsite';
|
@ -5,7 +5,13 @@ export class SitemapNews {
|
|||||||
|
|
||||||
constructor(optionsArg: {}) {}
|
constructor(optionsArg: {}) {}
|
||||||
|
|
||||||
public async readAndAddFromRssFeed(urlArg: string) {
|
public async readAndAddFromRssFeedString(feedStringArg: string) {
|
||||||
|
const smartfeedInstance = new plugins.smartfeed.Smartfeed();
|
||||||
|
const parsedFeed = await smartfeedInstance.parseFeedFromString(feedStringArg);
|
||||||
|
this.items = this.items.concat(parsedFeed.items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async readAndAddFromRssFeedUrl(urlArg: string) {
|
||||||
const smartfeedInstance = new plugins.smartfeed.Smartfeed();
|
const smartfeedInstance = new plugins.smartfeed.Smartfeed();
|
||||||
const parsedFeed = await smartfeedInstance.parseFeedFromUrl(urlArg);
|
const parsedFeed = await smartfeedInstance.parseFeedFromUrl(urlArg);
|
||||||
this.items = this.items.concat(parsedFeed.items);
|
this.items = this.items.concat(parsedFeed.items);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { SitemapNews } from './smartsitemap.classes.sitemapnews';
|
import { SitemapNews } from './smartsitemap.classes.sitemapnews';
|
||||||
|
import { IUrlInfo, SitemapWebsite } from './smartsitemap.classes.sitemapwebsite';
|
||||||
import * as plugins from './smartsitemap.plugins';
|
import * as plugins from './smartsitemap.plugins';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
export class SmartSitemap {
|
export class SmartSitemap {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
@ -9,14 +11,34 @@ export class SmartSitemap {
|
|||||||
*/
|
*/
|
||||||
public async createSitemapNewsFromFeedUrl(feedUrlArg: string): Promise<string> {
|
public async createSitemapNewsFromFeedUrl(feedUrlArg: string): Promise<string> {
|
||||||
const sitemapNewsInstance = new SitemapNews({});
|
const sitemapNewsInstance = new SitemapNews({});
|
||||||
await sitemapNewsInstance.readAndAddFromRssFeed(feedUrlArg);
|
await sitemapNewsInstance.readAndAddFromRssFeedUrl(feedUrlArg);
|
||||||
return sitemapNewsInstance.exportSitemapXml();
|
return sitemapNewsInstance.exportSitemapXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a normal sitemap from a list of urls
|
* creates a normal sitemap from a list of urls
|
||||||
*/
|
*/
|
||||||
public async createSitemapFromYmlString(yamlString: string) {
|
public async createSitemapFromYmlString(yamlString: string): Promise<string> {
|
||||||
const yamlObject = await plugins.smartyaml.yamlStringToObject(yamlString);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user