multi-sitemap
Advanced tools
Comparing version 0.3.1-alpha.1 to 0.3.1-alpha.2
@@ -43,6 +43,7 @@ "use strict"; | ||
it('can handle a mix of static and dynamic sitemaps', function () { return __awaiter(_this, void 0, void 0, function () { | ||
var writer, processor, addStaticResult, addDynamicResult, addIndexResult; | ||
var now, writer, processor, addStaticResult, addDynamicResult, addIndexResult; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
now = new Date(); | ||
writer = new SitemapWriterMock_1.default(); | ||
@@ -71,3 +72,3 @@ processor = new SitemapProcessor_1.default({ | ||
_a.sent(); | ||
addIndexResult = processor.addIndex(); | ||
addIndexResult = processor.addIndex({ lastModified: now }); | ||
expect(addIndexResult).toBeInstanceOf(Promise); | ||
@@ -79,7 +80,22 @@ return [4 /*yield*/, addIndexResult]; | ||
index: [ | ||
{ url: 'https://domain.tld/sitemap/pages.xml' }, | ||
{ url: 'https://domain.tld/sitemap/products-1.xml' }, | ||
{ url: 'https://domain.tld/sitemap/products-2.xml' }, | ||
{ url: 'https://domain.tld/sitemap/products-3.xml' }, | ||
{ url: 'https://domain.tld/sitemap/products-4.xml' } | ||
{ | ||
url: 'https://domain.tld/sitemap/pages.xml', | ||
lastModified: now | ||
}, | ||
{ | ||
url: 'https://domain.tld/sitemap/products-1.xml', | ||
lastModified: now | ||
}, | ||
{ | ||
url: 'https://domain.tld/sitemap/products-2.xml', | ||
lastModified: now | ||
}, | ||
{ | ||
url: 'https://domain.tld/sitemap/products-3.xml', | ||
lastModified: now | ||
}, | ||
{ | ||
url: 'https://domain.tld/sitemap/products-4.xml', | ||
lastModified: now | ||
} | ||
], | ||
@@ -86,0 +102,0 @@ pages: ['https://domain.tld/', 'https://domain.tld/about'], |
@@ -22,4 +22,6 @@ import { ISitemapReader, ISitemapWriter, SitemapEntryConfig } from './types'; | ||
}): Promise<void>; | ||
addIndex(): Promise<void>; | ||
addIndex({lastModified}?: { | ||
lastModified: Date; | ||
}): Promise<void>; | ||
private mapEntriesToFullUrls(entries); | ||
} |
@@ -145,20 +145,22 @@ "use strict"; | ||
}; | ||
SitemapProcessor.prototype.addIndex = function () { | ||
SitemapProcessor.prototype.addIndex = function (_a) { | ||
var lastModified = (_a === void 0 ? { lastModified: new Date() } : _a).lastModified; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
var stream, entries; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.writer.createStream('index')]; | ||
case 1: | ||
stream = _a.sent(); | ||
stream = _b.sent(); | ||
entries = this.sitemapFilenames.map(function (filename) { return ({ | ||
url: _this.publicDirectory + "/" + filename | ||
url: _this.publicDirectory + "/" + filename, | ||
lastModified: lastModified | ||
}); }); | ||
return [4 /*yield*/, stream.add(this.mapEntriesToFullUrls(entries))]; | ||
case 2: | ||
_a.sent(); | ||
_b.sent(); | ||
return [4 /*yield*/, stream.end()]; | ||
case 3: | ||
_a.sent(); | ||
_b.sent(); | ||
return [2 /*return*/]; | ||
@@ -165,0 +167,0 @@ } |
{ | ||
"name": "multi-sitemap", | ||
"version": "0.3.1-alpha.1", | ||
"version": "0.3.1-alpha.2", | ||
"description": "Painless creation of large dynamic sitemaps that consist of multiple files.", | ||
@@ -12,3 +12,3 @@ "repository": "https://github.com/amannn/multi-sitemap", | ||
"prepublish": "yarn run build", | ||
"build": "yarn run test && rm -rf ./dist && tsc", | ||
"build": "yarn lint && yarn test && rm -rf ./dist && tsc", | ||
"test": "jest" | ||
@@ -15,0 +15,0 @@ }, |
52620
1002