Expose frontmatter in plugin-content-docs client hooks #9263
Labels
closed: duplicate
This issue or pull request already exists in another issue or pull request
feature
This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Have you read the Contributing Guidelines on issues?
Description
Currently, the only properties available are
id
path
sidebar
...when accessing the data through one of Docusaurus' client hooks (ex:
useGlobalData
oruseDocusaurusContext
). It would be great if we could get some more metadata in these objects. Some properties that could be included could be:frontmatter
- A record that contains frontmatter data for the relevant documentmarkdown
- A string that contains the markdown contentI realise that exposing the markdown could be a challenge, especially considering the fact that pages can be written in MDX. Maybe that wouldn't be necessary for my specific use case.
Has this been requested on Canny?
No response
Motivation
I want to create a "internal link preview" component that when hovered, shows a popover that contains a small preview of the document that the user is linking to.
I'm currently able to "find" the document, but I'm not getting enough relevant information to render a preview of the document. If I receive the frontmatter, atleast I can show a title and description.
API design
Currently,
docusaurus-plugin-content-docs
exposes this data to the client hooks:But if the frontmatter is available, it would be great to also get that in the doc-object:
Have you tried building it?
Yes I've tried looking into every client API available to see if it was possible to render a document preview from a React component, but alas it seems to not be possible given the current API of
docusaurus-plugin-content-docs
(since it doesn't expose enough information about the documents).Self-service
The text was updated successfully, but these errors were encountered: