refactor: rename variable and adding some comments

This commit is contained in:
Luis Contreras 2020-10-09 01:39:14 +02:00
parent cfabae56d7
commit a8afcfe6b6
2 changed files with 4 additions and 2 deletions

View file

@ -6,6 +6,7 @@ function sourceNodes({ actions, createNodeId, createContentDigest }) {
people people
.sort(() => Math.random() - 0.5) .sort(() => Math.random() - 0.5)
.forEach(p => { .forEach(p => {
// Remove duplicated tags.
const person = { ...p, tags: [...new Set(p.tags)] }; const person = { ...p, tags: [...new Set(p.tags)] };
const nodeMeta = { const nodeMeta = {
id: createNodeId(`person-${person.name}`), id: createNodeId(`person-${person.name}`),

View file

@ -3,8 +3,9 @@ import people from '../data.js';
function merge(prop) { function merge(prop) {
return function(acc, obj) { return function(acc, obj) {
const propEntries = [...new Set(obj[prop])]; // Remove duplicated values.
return [...propEntries, ...acc]; const values = [...new Set(obj[prop])];
return [...values, ...acc];
}; };
} }