Join the Webstudio community

Updated 3 months ago

'filtering' collection items

At a glance
I just want to confirm this is the best way to do this. If I am pulling in a collection of posts, but I want to display posts of a specific tag in one section of the page and then posts of another tag in another section. I would simply add the collections in different sections and put a visibility condition to filter for the items i want? It works. Just confirming this is best practice.
Attachment
image.png
J
S
4 comments
This will work. Two things to consider:

  1. You're looking for the first tag. What if publication is the second tag? I recall in a previous thread I showed a way to access the "primary tag" which I suppose you can set in Ghost.
  1. There's no guarantee you'll have enough posts of each type to fill up your grid. This won't be a problem until you scale though and have more than however many is the limit in their api (e.g. you have 200 posts in Ghost but only get 100 at a time via the API).
On the webstudio site, I make a separate API call for each tag I want on this page https://webstudio.is/blog
The API is very fast and the overview page can afford an extra 100 ms or so of loading time. I wouldnt take that trade off on an actual blog post though
This all makes sense. Thanks John.
Add a reply
Sign up and join the conversation on Discord