DEV Community

Discussion on: Dynamic Sitemaps with Contentful and Next.js a.k.a 'look ma no webhooks'

Collapse
 
asherccohen profile image
Asher Cohen

Hi!Great article, well done. Just a quick note, I think you're missing a piece as posts.items is flagged as not defined.

Maybe you want to add something like:

    const posts = await client.getEntries({
        content_type: 'post',
        limit: 1000,
        include: 1,
    });
Collapse
 
mrispoli24 profile image
Mike Rispoli

Hi Asher,

So for this section of code the posts.items will come back as undefined if you don't have a content_type of posts inside your Contentful account. You would probably want to wrap that in an if statement in production in case your content_type returns no items. But you will likely have multiple types you want to add here for example posts, pages, categories, etc. Anything that represents a page that you want to expose to google.