How've you at Prismic structured your guides?

I really dig the guides page that you guys have. When I select a guide, it takes me to the blog post for that link.

So guides are a cluster of individual blog posts.

Ok. I can set that up easily.

But then when in the blog post, all the topics for the guide to which the post belongs appear as navigation.

If a blog isn't a part of a guide, then there's no navigation.

How have you guys set this up, and how're you making the queries efficiently?

Please, I need to set up such a structure asap, so help me out with this info.

Hey, great question!

For this we're using two page types that we've called blog and blog_guide.

For the blog_guide, there are title fields and other fields for the content you see on this page: The Complete Guide to Headless CMS
And there's also a repeatable group with a link that only lets you link to blog types.

On blog we've added a third tab called Guide that has a content relationship to link it to the guide it belongs to.

So the blog guide type is pointing at the blog posts, and each blog post is pointing back at the blog guide.

In the code for the Guide homepage (The Complete Guide to Headless CMS for example) we query that document and get each connected blog's title and image with the Fetch links feature.

In the code for the blog post page, we get that document and then check the part_of_guide field to see if it's filled. If it is, we query for the blog guide and get the list of all blog posts. In our layout component we check to see if guide exists. If it does, we show the guide bar, otherwise it doesn't render.

I didn't create this, @samuelhorn did, but I peeked at the (private) code to find out.

Let me know if you have any further questions, and I hope that helps!

1 Like