sitemap-generator-custom-volodzya
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "sitemap-generator-custom-volodzya", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A library to generate sitemaps in various formats", | ||
@@ -5,0 +5,0 @@ "main": "src/SitemapGenerator.js", |
@@ -7,36 +7,13 @@ const fs = require('fs'); | ||
class SitemapGenerator { | ||
constructor(basePath, fileType, filePath) { | ||
this.basePath = basePath; | ||
constructor(pages, fileType, filePath) { | ||
this.pages = pages; | ||
this.fileType = fileType; | ||
this.filePath = filePath; | ||
this.pages = this.getPages(this.basePath); | ||
this.validatePages(this.pages); | ||
this.generateSitemap(); | ||
} | ||
getPages(dir, baseURL = '') { | ||
let pages = []; | ||
const files = fs.readdirSync(dir); | ||
files.forEach(file => { | ||
const fullPath = path.join(dir, file); | ||
const stat = fs.statSync(fullPath); | ||
if (stat.isDirectory()) { | ||
pages = pages.concat(this.getPages(fullPath, path.join(baseURL, file))); | ||
} else if (file.endsWith('.html')) { | ||
pages.push({ | ||
loc: path.join(baseURL, file).replace(/\\/g, '/'), | ||
lastmod: stat.mtime.toISOString().split('T')[0], | ||
changefreq: 'daily', | ||
priority: '0.5' | ||
}); | ||
} | ||
}); | ||
return pages; | ||
} | ||
validatePages(pages) { | ||
@@ -43,0 +20,0 @@ for (const page of pages) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4952
106