contentful-metalsmith
contentful-metalsmith copied to clipboard
Many content types on one page
Is it possible to list two or more content types on one page?
Lets say I have events and news content types and I want both of them listed on one page.
Hi @pangorgo,
I didn't try this but you can specify content_type to * but then you will need to do more filtering
---
title: metalsmith-contentful file
contentful:
content_type: *
layout: post.html
layout: posts.html
---
One better suggestion, you can have on content_type called page for example and inside of it, you have a reference field that points to either event content_type or news content_type. so this way you can specify one content_type: page and you can display content of both events and news
---
title: metalsmith-contentful file
contentful:
content_type: page
layout: post.html
layout: posts.html
---
and inside you template you check if the reference name for example is 'event' you display something and if the name is news you display something else
{{#if fields.tage.name === 'events'}}
// display events data
{{/if}}
👍 for a page model.
What you could do also (depending on your use case) you could put several calls in the common section.
https://github.com/stefanjudis/stefan-judis-website/blob/master/build.js#L50-L77 https://github.com/contentful/contentful-metalsmith/blob/master/docs/global-settings.md#common-optional