fix(builders): skip articles without URLs when importing into sitemap builders

This commit is contained in:
2026-04-30 10:34:17 +00:00
parent 23fbf6ef1a
commit c9254e8a90
9 changed files with 597 additions and 2658 deletions
+1 -1
View File
@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartsitemap',
version: '4.0.1',
version: '4.0.2',
description: 'A comprehensive TypeScript sitemap library with builder API, supporting standard, news, image, video, and hreflang sitemaps with auto-splitting, streaming, validation, and RSS feed integration.'
}
+3
View File
@@ -76,6 +76,9 @@ export class NewsSitemapBuilder extends UrlsetBuilder {
*/
importFromArticles(articles: plugins.tsclass.content.IArticle[]): this {
for (const article of articles) {
if (!article.url) {
continue;
}
this.add({
loc: article.url,
lastmod: article.timestamp ? new Date(article.timestamp) : undefined,
+3
View File
@@ -149,6 +149,9 @@ export class UrlsetBuilder {
/** Import from @tsclass/tsclass IArticle array */
importFromArticles(articles: plugins.tsclass.content.IArticle[]): this {
for (const article of articles) {
if (!article.url) {
continue;
}
const url: interfaces.ISitemapUrl = {
loc: article.url,
lastmod: article.timestamp ? new Date(article.timestamp) : undefined,