-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
This is a current limitation of Docusaurus: each plugin is kind-of sandboxed:
A solution to this problem would be to "enhance" the default plugins to register a part of their data as "global data". That data would become available everywhere through In your case, if the goal is to render this data in a footer on all pages, then global data is appropriate because at least the data you put in there will be useful on all pages of your site (which is not always the case). Here's a runnable example explaining how to do so: #4138 (comment) import type { LoadContext, Plugin } from '@docusaurus/types';
import blogPlugin, { type BlogContent } from '@docusaurus/plugin-content-blog';
import type { PluginOptions as BlogPluginOptions } from '@docusaurus/plugin-content-blog';
export { validateOptions } from '@docusaurus/plugin-content-blog';
export default async function myCustomBlogPlugin(
context: LoadContext,
options: BlogPluginOptions
): Promise<Plugin<BlogContent>> {
const blogPluginInstance = await blogPlugin(context, options);
return {
...blogPluginInstance,
async contentLoaded({ content, actions }) {
await blogPluginInstance.contentLoaded({ content, actions });
actions.setGlobalData({MY_CUSTOM_BLOG_FOOTER_DATA});
},
};
}In the future, React Server Components should help us interleave data from various plugins on any page without paying the "cost of global data size". Track #9089 |
Beta Was this translation helpful? Give feedback.

This is a current limitation of Docusaurus: each plugin is kind-of sandboxed:
A solution to this problem would be to "enhance" the default plugins to register a part of their data as "global data". That data would become available everywhere through
useGlobalData(), but it would also make that data load every time you browse any page, so you'd rather keep it as slim as possible.In your case, if the goal is to render this data in a footer on all pages, then global data is appropriate because at least the data you put in there will be useful on all pages of your site (which is not always the case).
Here's a runnable example…