-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
actions.getCollection always returns undefined in plugin #1342
Comments
Is Anyway.. i have tested it with //gridsome.config.js
module.exports = {
siteName: 'Gridsome',
plugins: [
{
use: '@gridsome/source-filesystem',
options: {
typeName: 'BlogPost',
path: './content/*.md',
}
}
]
} I got a response with and without
Result is something like this:
I assume you're using a remote source - it's possible that the collection doesn't exists at the moment. We solved the problem with the remote sources after moving the logic into the |
@noxify Thanks for the fast response. I´m using the source-filesystem as well as my only file source besides https://gridsome.org/plugins/gridsome-source-static-meta (which is not what I´m trying to access). No remote source. Sync and async produce the same result, however I´ve now tried to fetch the collection once in my plugin I´m trying to develop and once in the application itself: Logs:
It works as expected in the application (or actual site) but not in the plugin project. This is all I´m doing in my gridsome-server.js of the plugin
Which is included in my project using yarn link Thanks, I´ll look into onCreateNode. Do you think it´s the right hook if you need to build relations between nodes? |
This depends of what you want to do :) We use the Example:
I will give it a try, to see if I can reproduce your problem. |
Ok... created shortly a local package with the following contents:
Then I ran Moved to the gridsome project root and ran Inside the
I have currently only one BUT, if I use the following plugin config inside the
Possible solution: |
@noxify Oh dear, you are right. I didn´t know the plugin order matters. Is this behaviour intentional or just a side effect? Thank you for your effort :) |
I have checked the code and there is no "load order" or something implemented. Question: Does this solve your problem for now? |
@noxify I´ve added a hint to the readme for now and an example where the source-filesystem plugin is above mine https://github.com/mklueh/gridsome-plugin-recommender Thank you very much for your help |
You're welcome :) BTW. Will check if I can integrate your plugin into our starters and replace the Tag based related posts. I will close this issue since we solved the problem :) |
Description
I need to iterate through a collection after it is created and modify some nodes based on information of other nodes.
My idea was to use actions.getCollection()
However, there is never a collection returned and I get undefined instead on all calls.
It´s not clear to me what is wrong with that code, because I´m just following the docs, but I´m assuming the callback is executed before the collections are created.
Appreciate any hints and tips on how to get collections after they are created to be able to modify them before the pages are created.
The text was updated successfully, but these errors were encountered: