Skip to content

Commit

Permalink
update logic to account for tags change from obj to array
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Kim authored and Chris Kim committed Dec 5, 2023
1 parent f898e20 commit b312c18
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
16 changes: 10 additions & 6 deletions src/site/filters/liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ module.exports = function registerFilters() {
const {
entity: {
fieldTopics = [],
fieldAudienceBeneficiares,
fieldAudienceBeneficiares = [],
fieldNonBeneficiares,
},
} = fieldTags;
Expand All @@ -810,17 +810,21 @@ module.exports = function registerFilters() {
categoryLabel: 'Topics',
}));

const audiences = [
fieldAudienceBeneficiares?.entity,
fieldNonBeneficiares?.entity,
]
const beneficiaresAudiences = fieldAudienceBeneficiares
.filter(tag => !!tag)
.map(audience => ({
...audience?.entity,
categoryLabel: 'Audience',
}));

const audiences = [fieldNonBeneficiares?.entity]
.filter(tag => !!tag)
.map(audience => ({
...audience,
categoryLabel: 'Audience',
}));

const tagList = [...topics, ...audiences];
const tagList = [...topics, ...audiences, ...beneficiaresAudiences];

return _.sortBy(tagList, 'name');
};
Expand Down
10 changes: 6 additions & 4 deletions src/site/filters/liquid.unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,11 +935,13 @@ describe('getTagsList', () => {
},
},
],
fieldAudienceBeneficiares: {
entity: {
name: 'C. Example',
fieldAudienceBeneficiares: [
{
entity: {
name: 'C. Example',
},
},
},
],
fieldNonBeneficiares: {
entity: {
name: 'D. Example',
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2777,9 +2777,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001252, caniuse-lite@^1.0.30001254:
version "1.0.30001259"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001259.tgz#ae21691d3da9c4be6144403ac40f71d9f6efd790"
integrity sha512-V7mQTFhjITxuk9zBpI6nYsiTXhcPe05l+364nZjK7MFK/E7ibvYBSAXr4YcA6oPR8j3ZLM/LN+lUqUVAQEUZFg==
version "1.0.30001566"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001566.tgz"
integrity sha512-ggIhCsTxmITBAMmK8yZjEhCO5/47jKXPu6Dha/wuCS4JePVL+3uiDEBuhu2aIoT+bqTOR8L76Ip1ARL9xYsEJA==

caseless@~0.12.0:
version "0.12.0"
Expand Down

0 comments on commit b312c18

Please sign in to comment.