diff --git a/src/site/filters/liquid.js b/src/site/filters/liquid.js index a3901471db..ecfef79de1 100644 --- a/src/site/filters/liquid.js +++ b/src/site/filters/liquid.js @@ -810,10 +810,19 @@ module.exports = function registerFilters() { categoryLabel: 'Topics', })); - const audiences = [ - fieldAudienceBeneficiares?.entity, - fieldNonBeneficiares?.entity, - ] + let beneficiaresAudiences = []; + if ( + fieldAudienceBeneficiares && + !Array.isArray(fieldAudienceBeneficiares) + ) { + beneficiaresAudiences = [fieldAudienceBeneficiares?.entity]; + } else if (fieldAudienceBeneficiares) { + beneficiaresAudiences = fieldAudienceBeneficiares.map( + audience => audience?.entity, + ); + } + + const audiences = [fieldNonBeneficiares?.entity, ...beneficiaresAudiences] .filter(tag => !!tag) .map(audience => ({ ...audience, diff --git a/src/site/filters/liquid.unit.spec.js b/src/site/filters/liquid.unit.spec.js index a8a71b97b0..59120978bb 100644 --- a/src/site/filters/liquid.unit.spec.js +++ b/src/site/filters/liquid.unit.spec.js @@ -935,11 +935,13 @@ describe('getTagsList', () => { }, }, ], - fieldAudienceBeneficiares: { - entity: { - name: 'C. Example', + fieldAudienceBeneficiares: [ + { + entity: { + name: 'C. Example', + }, }, - }, + ], fieldNonBeneficiares: { entity: { name: 'D. Example', diff --git a/src/site/stages/build/plugins/create-resources-and-support-section.js b/src/site/stages/build/plugins/create-resources-and-support-section.js index 34107890b7..b5d5f78f85 100644 --- a/src/site/stages/build/plugins/create-resources-and-support-section.js +++ b/src/site/stages/build/plugins/create-resources-and-support-section.js @@ -74,7 +74,13 @@ function groupByTags(allArticles) { const terms = [...fieldTopics]; if (fieldAudienceBeneficiares) { - terms.push(fieldAudienceBeneficiares); + if (!Array.isArray(fieldAudienceBeneficiares)) { + terms.push({ ...fieldAudienceBeneficiares }); + } else { + fieldAudienceBeneficiares.forEach(tag => { + terms.push(tag); + }); + } } if (fieldNonBeneficiares) {