Supporting value wrap in summary template.

This commit is contained in:
DebaucheryLibrarian 2024-08-29 02:19:57 +02:00
parent e3ed54fe3c
commit aa3eb3df33
1 changed files with 4 additions and 6 deletions

View File

@ -48,13 +48,11 @@ function curateValue(value, item) {
.slice(0, item.limit || Infinity)
.map((listValue) => (item.slugify ? slugify(listValue, item.slugify) : listValue))
.map((listValue) => ellipsis(listValue, item.slice || Infinity, item.ellipsis || ''))
.map((listValue) => `${item.wrap?.[0] || ''}${listValue}${item.wrap?.[1] || ''}`)
.join(item.delimit || ', ');
}
function traverseTemplate(chain, release, {
delimit = ' ',
wrap = ['', ''],
} = {}) {
function traverseTemplate(chain, release, { delimit = ' ' } = {}) {
const results = chain.reduce((result, item) => {
const keys = typeof item === 'string' ? item : item.key;
@ -77,7 +75,6 @@ function traverseTemplate(chain, release, {
if (item.items) {
const group = traverseTemplate(item.items, release, {
delimit: item.delimit,
wrap: item.wrap,
});
return result.concat(curateValue(group, item));
@ -87,7 +84,8 @@ function traverseTemplate(chain, release, {
}, []);
if (results.length > 0) {
return `${wrap[0] || ''}${results.filter(Boolean).join(delimit)}${wrap[1] || ''}`;
// return `${wrap[0] || ''}${results.filter(Boolean).join(delimit)}${wrap[1] || ''}`;
return results.filter(Boolean).join(delimit);
}
return '';