score:1
you should be able to use something similar to your category method:
items = tempitems.filter(({ node }) =>
node.tag.map(tag => tag.title).includes("tag2")
);
since this isn't necessarily react / gatsby specific, here is only the data and these methods:
const data = {
data: {
menu: {
edges: [{
node: {
title: "articlename 1",
slug: "articlename-1",
category: {
title: "cat1"
},
tag: [{
title: "tag1"
},
{
title: "tag2"
},
{
title: "tag3"
}
]
}
},
{
node: {
title: "articlename 2",
slug: "articlename-2",
category: {
title: "cat2"
},
tag: [{
title: "tag3"
}]
}
}
]
}
}
};
let items = data.data.menu.edges.filter(
({
node
}) => node.category.title === "cat2"
);
console.log(items);
items = data.data.menu.edges.filter(({
node
}) =>
node.tag.map(tag => tag.title).includes("tag2")
);
console.log(items);
Source: stackoverflow.com
Related Query
- How to map nested array in gatsby with reactjs and graphql
- React Hooks: how to properly map an array with nested arrays and objects inside a select element?(new coder)
- How to compare nested array with the map or filter and only return with first match inside?
- How do I map my Union typed GraphQL response Array in React and Typescript
- How to map nested JSON properties collected with JS fetch API and SWR
- How do I get the "results" object nested in the array "news" and map over it?
- How can I shuffle an array of objects on page render and map over the shuffled array without console warning of "two children with the same key"?
- How to access Nested Object with Map in ReactJS
- I have a multidimensional object with several layers of nested arrays and I'm trying to map through all of them in one go but not sure how to
- Nested array with React and Firestore - How to display?
- Displaying JSON multi-dimensional array data with ReactJS and map
- Reactjs and Javascript: how to map a nested object to input field
- How to update an array of objects with clickHandler and useState in Reactjs
- How to iterate with Object Dot Keys and Array Dot Map to display data in a component?
- how to correctly map an obj and return a single value with several identical values ReactJS
- How to filter Dynamic nested array of JSON objects based on text match with both upper and lower case
- How map with function and text ReactJs
- How can I set a specific position to array elements with the map function and a given index?
- ReactJS - Rending Map Function with Nested Array in Prop
- How to map through an Array of object with the same data on some object and get it displayed once and also get other properties
- How can I map array with multiple objects and display on chart?
- How to map through array of objects and create a new array of objects with a new added property using react and javascript?
- How can I use an array map of routes with BrowserRouter and Switch without them all loading at once?
- How to disassemble an array of objects and nested arrays to Separated arrays with single data
- How can I use Map function for an Array with values and another array as a value in Javascript
- How to render bootstrap grid from array with map in reactjs
- How to have nested loops with map in JSX?
- How to make react router work with static assets, html5 mode, history API and nested routes?
- How to test a component with a nested container with React and Redux?
- Gatsby and Graphql - How to filter allMarkdownRemark by folder
More Query from same tag
- Not able to pass data to child react component
- How to change the style of the navbar on scrolling?
- react hooks typescript how to update state
- axios baseUrl not working in react when using process.env
- Input search field created by React works incorrectly
- How to create array list from for loop in react
- Can I type React Children using Typescript?
- How to increment the filename if file already exists in javascript
- Option value is not appearing when selected in drop down box
- React .map not re-rendering
- React Router navigation URL is appended to existing URL
- Will there be an issue when this.setState is used inside of .then?
- how to expand only one collapse panel in ant-design
- How to display each item in an array in React JS?
- Dialog Material-UI Scroll start from bottom
- Runtime environment variable for react app
- Why does this error stop the rendering of my react app?
- Redirect to login page when token is invalid on React
- Why does my input still stay after i hit Submit?
- Redux State Not Updated In Dev Tools But Current State Is Being Reflected In Props
- Is it possible to mock schema fields in GaphQL request in react-query like apolloclient does it?
- How to assign a prop value to a state in react
- How do I render images on the webpage in react from an array?
- ReactJS: [ this.props ] being impossibly different to [ props in this ]
- How is this javascript object destructuring working?
- How does React call the render function of an ES6 class in a such a way that `this` does not refer to the class itself?
- Uncaught (in promise) Error: Network Error at createError
- How can I get localStorage to work with ReactJS?
- align title header above body component using css for react app
- React-Bootstrap NavItem not Firing onClick Handler