From cfabae56d7066105dae25e2b66307f9772b027ad Mon Sep 17 00:00:00 2001 From: Luis Contreras Date: Fri, 9 Oct 2020 01:21:44 +0200 Subject: [PATCH] fix: ignore duplicated tags --- gatsby-node.js | 3 ++- src/util/stats.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 8f64c729..f3084861 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -5,7 +5,8 @@ function sourceNodes({ actions, createNodeId, createContentDigest }) { // Add People to the GraphQL API, we randomize the data on each build so no one gets their feelings hurt people .sort(() => Math.random() - 0.5) - .forEach(person => { + .forEach(p => { + const person = { ...p, tags: [...new Set(p.tags)] }; const nodeMeta = { id: createNodeId(`person-${person.name}`), parent: null, diff --git a/src/util/stats.js b/src/util/stats.js index d41e05d8..862cf86b 100644 --- a/src/util/stats.js +++ b/src/util/stats.js @@ -3,7 +3,8 @@ import people from '../data.js'; function merge(prop) { return function(acc, obj) { - return [...obj[prop], ...acc]; + const propEntries = [...new Set(obj[prop])]; + return [...propEntries, ...acc]; }; }