Merge pull request #987 from devrasec/ignore-duplicated-tags

Ignore duplicated tags
This commit is contained in:
Wes Bos 2020-10-12 14:50:41 -04:00 committed by GitHub
commit 1e35464605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -5,7 +5,9 @@ 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 // Add People to the GraphQL API, we randomize the data on each build so no one gets their feelings hurt
people people
.sort(() => Math.random() - 0.5) .sort(() => Math.random() - 0.5)
.forEach(person => { .forEach(p => {
// Remove duplicated tags.
const person = { ...p, tags: [...new Set(p.tags)] };
const nodeMeta = { const nodeMeta = {
id: createNodeId(`person-${person.name}`), id: createNodeId(`person-${person.name}`),
parent: null, parent: null,

View file

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