Manipulating a Javascript Object

Viewed 21

Good evening,

Working in Gatsby I have an object returned from a GraphQL query that contains all of my posts and is structured as follows:

{
    "nodes": [
        {
            "frontmatter": {
                "excerpt": null,
                "featured": true,
                "slug": "posts/a-post-of-type-page",
                "title": "A Post with Content"
            }
        },
        {
            "frontmatter": {
                "excerpt": null,
                "featured": null,
                "slug": "posts/a-post-of-type-post",
                "title": "A post of type post"
            }
        },
        {
            "frontmatter": {
                "excerpt": null,
                "featured": null,
                "slug": "posts/another-post-or-type-post",
                "title": "Another Post (or type post)"
            }
        },
        {
            "frontmatter": {
                "excerpt": "This is the excerpt of a post",
                "featured": null,
                "slug": "posts/with-content",
                "title": "With Content"
            }
        },
        {
            "frontmatter": {
                "excerpt": null,
                "featured": null,
                "slug": "posts/a-post-of-type-page2",
                "title": "A post of type post 2"
            }
        }
    ]
}

I've been trying to work with the filter to extract an object with posts that match a slug or array of slugs. I'm struggling with the fact that slug is two deep in the object. Ideally I would like to return a filtered object with the frontmatter level 'removed'. Any help would be appreciated.

Thanks

0 Answers
Related