|
| 1 | +import { Streamdown } from "@lobehub/streamdown"; |
| 2 | +import { Block, Typography } from "@lobehub/ui"; |
| 3 | +import { useMemo } from "react"; |
| 4 | +import remarkGfm from "remark-gfm"; |
| 5 | + |
| 6 | +import { markdownComponents } from "../../src/Streamdown/demos/shared/markdownComponents"; |
| 7 | + |
| 8 | +// The original site's API card (f3ba7b3:site/src/lib/samples.ts `apiReference`), updated to the |
| 9 | +// current StreamdownProps in src/Streamdown.tsx (adds `remend`). |
| 10 | +const API_REFERENCE = `| Prop | Type | Default | Description | |
| 11 | +| --- | --- | --- | --- | |
| 12 | +| \`content\` | \`string\` | — | The (partial) markdown to render | |
| 13 | +| \`smoothing\` | \`'realtime' \\| 'balanced' \\| 'silky'\` | \`'balanced'\` | Reveal pacing preset | |
| 14 | +| \`granularity\` | \`'char' \\| 'word'\` | \`'char'\` | Fade animation unit | |
| 15 | +| \`latexGuard\` | \`boolean\` | \`false\` | Hold last frame while trailing formula is incomplete | |
| 16 | +| \`preprocess\` | \`(text: string) => string\` | — | Transform content before rendering | |
| 17 | +| \`remend\` | \`RemendOptions\` | — | Options for the remend pass on the open tail block | |
| 18 | +| \`components\` / \`remarkPlugins\` / \`rehypePlugins\` | — | — | Passed through to react-markdown | |
| 19 | +
|
| 20 | +Lower-level hooks — \`useSmoothStreamContent\`, \`useStreamQueue\`, |
| 21 | +\`rehypeStreamAnimated\` and the LaTeX preprocessing helpers — are exported for |
| 22 | +custom pipelines. Profiling lives in \`@lobehub/streamdown/profiler\`. |
| 23 | +
|
| 24 | +### Limitation: cross-block references |
| 25 | +
|
| 26 | +Each top-level block is parsed independently, so a reference whose target sits in |
| 27 | +another block stays literal: GFM footnotes, reference-style links |
| 28 | +(\`[text][ref]\`) and reference-style images. Inline forms are unaffected. Supply |
| 29 | +a remark/rehype plugin pair if you need to resolve these out of band. |
| 30 | +`; |
| 31 | + |
| 32 | +export const ApiSection = () => { |
| 33 | + const remarkPlugins = useMemo(() => [remarkGfm], []); |
| 34 | + |
| 35 | + return ( |
| 36 | + <Block padding={24} variant={"outlined"} width={"100%"}> |
| 37 | + <Typography fontSize={14}> |
| 38 | + <Streamdown |
| 39 | + components={markdownComponents} |
| 40 | + content={API_REFERENCE} |
| 41 | + remarkPlugins={remarkPlugins} |
| 42 | + /> |
| 43 | + </Typography> |
| 44 | + </Block> |
| 45 | + ); |
| 46 | +}; |
0 commit comments