multi-sitemap
Advanced tools
Comparing version 0.3.0-2 to 0.3.0-3
@@ -49,5 +49,5 @@ "use strict"; | ||
processor = new SitemapProcessor_1.default({ | ||
hostname: 'https://domain.tld', | ||
publicHost: 'https://domain.tld', | ||
maxEntriesPerFile: 2, | ||
publicDirectoryUrl: '/sitemap', | ||
publicDirectory: '/sitemap', | ||
writer: writer | ||
@@ -54,0 +54,0 @@ }); |
import { ISitemapReader, ISitemapWriter, SitemapEntryConfig } from './types'; | ||
export default class SitemapProcessor { | ||
private hostname; | ||
private publicHost; | ||
private maxEntriesPerFile; | ||
private publicDirectoryUrl; | ||
private publicDirectory; | ||
private sitemaps; | ||
private writer; | ||
constructor({hostname, maxEntriesPerFile, publicDirectoryUrl, writer}: { | ||
hostname: string; | ||
constructor({publicHost, maxEntriesPerFile, publicDirectory, writer}: { | ||
publicHost: string; | ||
maxEntriesPerFile?: number; | ||
publicDirectoryUrl: string; | ||
publicDirectory: string; | ||
writer: ISitemapWriter; | ||
@@ -13,0 +13,0 @@ }); |
@@ -48,15 +48,15 @@ "use strict"; | ||
function SitemapProcessor(_a) { | ||
var hostname = _a.hostname, _b = _a.maxEntriesPerFile, maxEntriesPerFile = _b === void 0 ? 50000 : _b, publicDirectoryUrl = _a.publicDirectoryUrl, writer = _a.writer; | ||
var publicHost = _a.publicHost, _b = _a.maxEntriesPerFile, maxEntriesPerFile = _b === void 0 ? 50000 : _b, publicDirectory = _a.publicDirectory, writer = _a.writer; | ||
this.sitemaps = []; | ||
// Ensure hostname ends without a trailing slash | ||
if (hostname.endsWith('/')) { | ||
hostname = hostname.slice(0, hostname.length - 1); | ||
// Ensure publicHost ends without a trailing slash | ||
if (publicHost.endsWith('/')) { | ||
publicHost = publicHost.slice(0, publicHost.length - 1); | ||
} | ||
this.hostname = hostname; | ||
this.publicHost = publicHost; | ||
this.maxEntriesPerFile = maxEntriesPerFile; | ||
// Ensure publicDirectoryUrl ends without a trailing slash | ||
if (publicDirectoryUrl.endsWith('/')) { | ||
publicDirectoryUrl = publicDirectoryUrl.slice(0, publicDirectoryUrl.length - 1); | ||
// Ensure publicDirectory ends without a trailing slash | ||
if (publicDirectory.endsWith('/')) { | ||
publicDirectory = publicDirectory.slice(0, publicDirectory.length - 1); | ||
} | ||
this.publicDirectoryUrl = publicDirectoryUrl; | ||
this.publicDirectory = publicDirectory; | ||
this.writer = writer; | ||
@@ -154,3 +154,3 @@ } | ||
entries = this.sitemaps.map(function (name) { return ({ | ||
url: _this.publicDirectoryUrl + "/" + name | ||
url: _this.publicDirectory + "/" + name | ||
}); }); | ||
@@ -175,3 +175,3 @@ return [4 /*yield*/, stream.add(this.mapEntriesToFullUrls(entries))]; | ||
url = '/' + url; | ||
url = _this.hostname + url; | ||
url = _this.publicHost + url; | ||
} | ||
@@ -178,0 +178,0 @@ if (typeof entryConfig === 'string') { |
{ | ||
"name": "multi-sitemap", | ||
"version": "0.3.0-2", | ||
"version": "0.3.0-3", | ||
"description": "Painless creation of large dynamic sitemaps that consist of multiple files.", | ||
@@ -5,0 +5,0 @@ "author": "Jan Amann <jan@amann.me>", |
@@ -19,4 +19,11 @@ # multi-sitemap | ||
const processor = new SitemapProcessor({ | ||
hostname: 'http://domain.tld', | ||
publicDirectoryUrl: '/sitemap', | ||
// The domain where the sitemap is hosted. A sitemap is | ||
// required to include a full URL including the host. | ||
publicHost: 'http://domain.tld', | ||
// The public path on the host where the sitemap can be | ||
// found. This will be concatenated with `publicHost`. | ||
publicDirectory: '/sitemap', | ||
// One of the pluggable writers. | ||
writer: new SitemapWriterXml({directory: './static/sitemap'}); | ||
@@ -23,0 +30,0 @@ }); |
51403
106