From a8afcfe6b6ce41129572fabd834a66ba1941e6d4 Mon Sep 17 00:00:00 2001 From: Luis Contreras Date: Fri, 9 Oct 2020 01:39:14 +0200 Subject: [PATCH] refactor: rename variable and adding some comments --- gatsby-node.js | 1 + src/util/stats.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index f3084861..a70e9aec 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -6,6 +6,7 @@ function sourceNodes({ actions, createNodeId, createContentDigest }) { people .sort(() => Math.random() - 0.5) .forEach(p => { + // Remove duplicated tags. const person = { ...p, tags: [...new Set(p.tags)] }; const nodeMeta = { id: createNodeId(`person-${person.name}`), diff --git a/src/util/stats.js b/src/util/stats.js index 862cf86b..f016702d 100644 --- a/src/util/stats.js +++ b/src/util/stats.js @@ -3,8 +3,9 @@ import people from '../data.js'; function merge(prop) { return function(acc, obj) { - const propEntries = [...new Set(obj[prop])]; - return [...propEntries, ...acc]; + // Remove duplicated values. + const values = [...new Set(obj[prop])]; + return [...values, ...acc]; }; }