Skip to content
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

Document how to produce a "json feed" containing all content as single JSON file #2312

Closed
trauts2 opened this issue Feb 22, 2020 · 4 comments
Labels
documentation The issue is related to the documentation of Docusaurus feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@trauts2
Copy link

trauts2 commented Feb 22, 2020

📚 Documentation

Similar to Hugo's index.json. I would like to know how to make a JSON output representing all site content and metadata. Like this:

https://www.screencast.com/t/a3spUYaU1J0

This supports a variety of downstream transformations of site content, such as building a custom Algolia index, transforming to other output formats, etc.

Could someone document or suggest how to do this?

Thanks!

Stu

Have you read the Contributing Guidelines on issues?

yes

@trauts2 trauts2 added documentation The issue is related to the documentation of Docusaurus status: needs triage This issue has not been triaged by maintainers labels Feb 22, 2020
@yangshun yangshun added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. and removed status: needs triage This issue has not been triaged by maintainers labels Feb 24, 2020
@yangshun
Copy link
Contributor

We don't have a good way to do that at the moment as we don't aggregate the data model during the bootstrap process into one single data structure, unlike Gatsby. Contents and data fetched within each plugin is scoped to that plugin. The only overall site-wide data we have is the routes, which is used by docusaurus-plugin-sitemap to create sitemap.xml.

But what you have proposed is a step in the right direction. In future, we would try to have similar APIs to build data models in plugins which can be processed downstream in subsequent plugins.

@slorber
Copy link
Collaborator

slorber commented Jun 10, 2021

The contentLoaded attribute now accept a "allContent" attribute that permits to access the content loaded by all the plugins.

async contentLoaded({actions: {createData, addRoute}, allContent}) {

Take a look at the official debug plugin for inspiration, as it access the data of all the plugins: https://docusaurus.io/__docusaurus/debug/content

There's also a plan to be able to extend existing content plugins, in case you want to do something with the loaded data of a single plugin. Check #4138, issue is a bit messy though, and there's no official API for this yet but you can work around that.

@slorber slorber closed this as completed Jun 10, 2021
@kesor
Copy link

kesor commented Sep 9, 2024

Migrated from v2 to v3 ... and there is no longer allContent available :(

@slorber
Copy link
Collaborator

slorber commented Sep 9, 2024

@kesor this is something we never documented because I wasn't sure it was a good idea.

We later refactored it to another lifecycle method you can try allContentLoaded. Again, still undocumented, we might not make it a public API surface and may need to refactor it if we find a better API design. But the "feature" should stay because we need it ourselves for the debug plugin: https://docusaurus.io/__docusaurus/debug/content

More context here: #9931

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation The issue is related to the documentation of Docusaurus feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

No branches or pull requests

4 participants