fix: allow tags to be optional in items

related to #430
This commit is contained in:
Mathias Schopmans
2024-03-13 14:47:33 +01:00
parent 04053c6700
commit 5750723c40
4 changed files with 11 additions and 8 deletions

View File

@@ -134,7 +134,7 @@ function getUniqueReleases(items: Item[]): string[] {
function getUniqueTags(items: Item[]): string[] {
const tags = new Set<string>();
for (const item of items) {
for (const tag of item.tags) {
for (const tag of item.tags || []) {
tags.add(tag);
}
}
@@ -187,7 +187,7 @@ function postProcessItems(items: Item[]): {
// check if config has a key `tags` and if it is an array
if (Array.isArray(tags) && tags.length) {
// if tags are specified, only keep items that have at least one of the tags
return item.tags.some((tag) => tags.includes(tag));
return item.tags?.some((tag) => tags.includes(tag));
}
return true;
@@ -219,6 +219,11 @@ function postProcessItems(items: Item[]): {
delete processedItem.revisions;
}
// unset tags if there are none
if (!processedItem.tags?.length) {
delete processedItem.tags;
}
return processedItem;
});