Repository navigation
Generate a documentation page in Markdown from a json description #6009
Replies: 2 comments 3 replies
|
We don't include any markdown component by default in Docusaurus because such libs add some decent size to the final JS bundle and parsing markdown syntax in the frontend also has a runtime cost that can slow down your page transitions. If you really want to do this you can add a lib like https://github.com/remarkjs/react-markdown yourself on pages. It adds weight but it might be ok for your site, it's up to you. Other more lightweight possibilities:
Note you do not need to use Markdown, you might as well create a comp that manually renders your API: export default function MyAPIComponent() {
return <>
{apiDescription.map(({title, description}) => (
<div>
<h2>${title}</h2>
<div>{description}</div>
</div>
))}
</>
}only problem is that Docusaurus wouldn't be able to compute a table of contents though |
|
@slorber Investigating the build time solution : I can't find any documented way in Docausorus to transform files at build time, e.g. with a simple node script that I would list somewhere, that would be picked at build time with hot reload support. Does it involves writing a simple plugin ? https://docusaurus.io/fr/docs/using-plugins Do I have to override the package.json scripts ? That looks quite complicated. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I have a JSON file describing an API with attributs like
titleanddescription, and would like to render a page in my Docusaurus documentation listing all these API. The description are written is markdown but I was unable to find a<Markdown />component that I can use.Essentialy I would like to display a generated markdown document like so
What is the recommanded way to generate a markdown page from an external data source? Also I'd would like to display a sidebar with all generated headings like for other pages.
All reactions