Split up an MDX files into headers for easy use in multiple parts of documentation
or in multiple files, with some added perks.
Currently, this breaks on any header such that a file like
# First Component
Something
## Second Component
```md # Second header description This second component does stuff ```
becomes essentially
{ "first-component": { full: [<h1>FirstComponent</h1>,<p>Something</p>], body: [<p>Something</p>], md:"", }, "second-component": { full: [<h1>SecondComponent</h1>,<p>Other</p>], body: [<code>....</code>], md:"# Second header description\nThis second component does stuff", }, }
Although actually they'll be functions at those locations that also have those properties,
but is () => full at invocation. Note how it picks up md code blocks as raw text, suitable
for story descriptions.
Split up an MDX files into headers for easy use in multiple parts of documentation or in multiple files, with some added perks.
Currently, this breaks on any header such that a file like
becomes essentially
Although actually they'll be functions at those locations that also have those properties, but is
() => full
at invocation. Note how it picks up md code blocks as raw text, suitable for story descriptions.Then you can use it like
And if you needed to combine them you could do something like
Or, in an mdx file like so (real example):
Uses a dead simple FIFO cache of size 50 just to avoid thinking about memory consumption issues.