Comparing version 2.4.0 to 2.5.0
@@ -1,4 +0,4 @@ | ||
export declare class MissingOption extends Error { | ||
export declare class MissingOptionError extends Error { | ||
constructor(missingOption: string | Array<string>); | ||
} | ||
//# sourceMappingURL=errors.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MissingOption = void 0; | ||
class MissingOption extends Error { | ||
exports.MissingOptionError = void 0; | ||
class MissingOptionError extends Error { | ||
constructor(missingOption) { | ||
@@ -9,3 +9,3 @@ super(`Sitemapy missing options in config: ${missingOption}`); | ||
} | ||
exports.MissingOption = MissingOption; | ||
exports.MissingOptionError = MissingOptionError; | ||
//# sourceMappingURL=errors.js.map |
@@ -6,10 +6,11 @@ "use strict"; | ||
const generateElement = (config, siteRoot) => { | ||
if (typeof config.url == 'undefined') { //must at minimum have url provided | ||
throw new errors_1.MissingOption("url"); | ||
if (typeof config.url == "undefined") { | ||
//must at minimum have url provided | ||
throw new errors_1.MissingOptionError("url"); | ||
} | ||
return `<url><loc>${siteRoot}/${config.url}</loc> | ||
return `<url><loc>${siteRoot}${config.url}</loc> | ||
${config.lastmod ? `<lastmod>${config.lastmod}</lastmod>` : ""} | ||
<priority>${config.priority}</priority> | ||
${config.changefreq ? `<changefreq>${config.changefreq}</changefreq>` : ""} | ||
</url>`.replace(/\s+/g, ''); | ||
</url>`.replace(/\s+/g, ""); | ||
}; | ||
@@ -26,3 +27,3 @@ exports.generateElement = generateElement; | ||
if (options.length > 0) { | ||
throw new errors_1.MissingOption(options); | ||
throw new errors_1.MissingOptionError(options); | ||
} | ||
@@ -29,0 +30,0 @@ }; |
@@ -10,3 +10,5 @@ "use strict"; | ||
const { siteRoot, pages } = config; | ||
let sitemap = start + pages.map(page => (0, helpers_1.generateElement)(page, siteRoot)).join("") + end; | ||
const sitemap = start + | ||
pages.map((page) => (0, helpers_1.generateElement)(page, siteRoot)).join("") + | ||
end; | ||
return sitemap; | ||
@@ -13,0 +15,0 @@ }; |
{ | ||
"name": "sitemapy", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Simple utility to generate sitemaps in xml, with zero dependencies", | ||
@@ -5,0 +5,0 @@ "main": "dist/sitemapy.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9156
70