-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
content in contentLoaded is always undefined #10574
Comments
Each plugin can only get its own content. If you didn't define I'm closing this for now since it's not a bug. If you have questions about how to implement a particular use case, please use GH discussions. |
Technically there's a secret allContentLoaded() hook you can use that received the whole site plugins content aggregated. It's used by our debug plugin. But it's internal and I'm likely to remove it, but if I ever do there will be an alternative option such as accessing the site content from the upcoming Server Components. So for an app I think it's relatively safe to implement this lifecycle until we have a better option. |
Yeah, I was using allContentLoaded for my plugin when that was one of the arguments to contentLoaded (maybe from docusaurus 2.x?) and it worked fine for a while. But then it stopped working when I upgraded from 3.1 to 3.5 and I saw what I was doing was not anywhere in the documentation, so clearly that was asking for trouble. I ended up seeing your reference for doing this (discussion example ) and that was super helpful. Using that code as a template, I was able to recreate my plugin but in a supported / working way. Thanks! |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
I want to use the contentLoaded api to get the content of my site.
I created the following plugin:
and added it to the plugins configuration in docusaurus.config.js. When I run yarn build, I get in the console:
but I'd expect to get the content of the site. Am I not using the async contentLoaded function correctly? And how can I get access to the content of the site for use in a plugin?
Reproducible demo
https://codesandbox.io/p/devbox/green-firefly-37w5c9
Steps to reproduce
Create plugin such as
try to use content.
Expected behavior
I would expect content to show the data associated with the site so that it can be parsed, etc.
Actual behavior
content is always undefined.
Your environment
Self-service
The text was updated successfully, but these errors were encountered: