You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to fetch related posts based on how many tags they have in common. A current implementation of that can be found in the Ghost Docs repository here. This code is very specific to the Ghost Docs requirements and also very messy.
There are probably better solutions to solve this, but this one works and can be a good starting point to create a plugin for the
Proposal
I had a play with this already, trying to add related posts to the GraphQL schema, but wasn't successful. This might be due to my lack of GraphQL knowledge, or simply because it's not possible that way.
The working solution in Ghost Docs inserts the related posts into the PageContext which is another option (not such a nice one, as having it available with a pretty GraphQL query) to implement this.
Maybe (probably) there are even better ways on doing that? This needs further research.
Todos
investigate do-ability and different options further
write up tech spec and agree on solution with core team
implement a general plugin for related Ghost posts, that can be configured
publish plugin
The text was updated successfully, but these errors were encountered:
which can be accessed with data.post, data.prev and data.next. The query parameters are computed in gatsby-node.js. This solution is very clean and does not pollute the PageContext.
@styxlab your link to your Casper fork is broken. I am really blocked as I would like to list all posts having the same tags as current post. Where you be able to solve that? Thanks
for anyone looking for a hacky solution to this, i've been able to get related posts showing
I'm not a GraphQL expert and this isn't a plugin but you can find the code used here. I'm basically using the allGhostPost query and then filtering that on the related tags manually, ideally you'd use the filter property inside that query but I couldn't figure out how to pass in the parameter to filter on.
It's not the greatest but I hope it helps someone who was stuck like me.
Problem description
It is possible to fetch related posts based on how many tags they have in common. A current implementation of that can be found in the Ghost Docs repository here. This code is very specific to the Ghost Docs requirements and also very messy.
There are probably better solutions to solve this, but this one works and can be a good starting point to create a plugin for the
Proposal
I had a play with this already, trying to add related posts to the GraphQL schema, but wasn't successful. This might be due to my lack of GraphQL knowledge, or simply because it's not possible that way.
The working solution in Ghost Docs inserts the related posts into the
PageContext
which is another option (not such a nice one, as having it available with a pretty GraphQL query) to implement this.Maybe (probably) there are even better ways on doing that? This needs further research.
Todos
The text was updated successfully, but these errors were encountered: