Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
Sitemap.sitemaps.map((sitemap, index) => {
const savePath = fileName.replace('.xml', `-${index}.xml`);
app.get(basePath + savePath, (req, res) => {
res.header('Content-Type', 'application/xml');
res.send(Sitemap.sitemaps[index].toString())
});
// push public path for indexing
sitemapPaths.push(Sitemap.hostname + publicPath + path.basename(savePath));
});
// create index string
const sitemapIndex = sm.buildSitemapIndex({
urls: sitemapPaths,
hostname: Sitemap.hostname
});
app.get(basePath + fileName, (req, res) => {
res.header('Content-Type', 'application/xml');
console.log(sitemapIndex)
res.send(sitemapIndex)
});
return app;
}
return this;
}
this.sitemaps.map((sitemap, index) => {
const savePath = dist.replace('.xml', `-${index}.xml`);
// write sitemap
fs.writeFileSync(savePath, sitemap.toString());
// push public path for indexing
sitemapPaths.push(this.hostname + publicPath + path.basename(savePath));
});
// create index string
const sitemapIndex = sm.buildSitemapIndex({
urls: sitemapPaths,
hostname: this.hostname
});
// write sitemap index
fs.writeFileSync(dist, sitemapIndex);
return this;
}
const hostname = getHostname(options.hostname ? options : { ...options, hostname: defaultHostname }, req, base)
const url = new URL(path, hostname)
return url.href
})
// Set lastmod for each sitemap
sitemapIndexConfig.lastmod = options.lastmod
// Set XML namespaces
sitemapIndexConfig.xmlNs = options.xmlNs
// Set XSL url
sitemapIndexConfig.xslUrl = options.xslUrl
// Create a sitemapindex
return sm.buildSitemapIndex(sitemapIndexConfig)
}
save(dist, publicPath = '/') {
const sitemapPaths = [];
this.sitemaps.forEach((sitemap, index) => {
const savePath = dist.replace('.xml', `-${index}.xml`);
fs.writeFileSync(savePath, sitemap.toString());
sitemapPaths.push(this.hostname + publicPath + path.basename(savePath));
});
const sitemapIndex = sitemap.buildSitemapIndex({
urls: sitemapPaths,
hostname: this.hostname,
});
fs.writeFileSync(dist, sitemapIndex);
return this;
}
}
return Promise.all(allSitemaps.map(writeSitemap)).then(filenames => {
const index = sitemap.buildSitemapIndex({
urls: filenames.map(filename => `${hostname}/sitemap/${filename}`)
});
const path = baseDirectory + 'sitemap.xml';
return fs.writeFile(path, oneLine(index)).then(() => Promise.resolve(path));
});
}).then(indexPath => {
generateSitemapIndex(filename: string) {
const urls = this.sitemaps.map(filename => `${this.hostname}/${filename}`);
this.saveToFile(buildSitemapIndex({ urls }).toString(), filename);
}
.then(async result => {
const datasetsPages = result.map(token => {
return baseExternalUri
.clone()
.path(
URI.joinPaths(
baseExternalUrl,
"sitemap/dataset/afterToken",
token.toString() + ".xml"
).href()
)
.href();
});
const smi = sm.buildSitemapIndex({
urls: [
baseExternalUri
.clone()
.path(
URI.joinPaths(
baseExternalUrl,
"sitemap/main.xml"
).href()
)
.href()
].concat(datasetsPages)
});
res.send(smi);
})
);