Skip to content

Commit 2221408

Browse files
committed
Support Markdown in Token API parameter & response descriptions
1 parent 830869c commit 2221408

File tree

3 files changed

+78
-5
lines changed

3 files changed

+78
-5
lines changed

pnpm-lock.yaml

Lines changed: 45 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
"react-dom": "^18.3.1",
4545
"react-ga4": "^2.1.0",
4646
"react-intersection-observer": "^9.16.0",
47+
"react-markdown": "^10.1.0",
4748
"rehype-mdx-code-props": "^3.0.1",
49+
"rehype-raw": "^7.0.0",
50+
"remark-gfm": "^4.0.1",
4851
"theme-ui": "^0.17.2",
4952
"unist-util-visit": "^5.0.0",
5053
"vfile": "^6.0.3",

website/src/layout/templates/openApi/content.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { type ComponentProps, Fragment, useContext } from 'react'
2+
import Markdown from 'react-markdown'
3+
import rehypeRaw from 'rehype-raw'
4+
import remarkGfm from 'remark-gfm'
25

3-
import { camelToKebab, ExperimentalCodeInline, ExperimentalSwitch, ExperimentalTag } from '@edgeandnode/gds'
6+
import {
7+
camelToKebab,
8+
ExperimentalCodeInline,
9+
ExperimentalLink,
10+
ExperimentalSwitch,
11+
ExperimentalTag,
12+
} from '@edgeandnode/gds'
413
import { CaretDown } from '@edgeandnode/gds/icons'
514

615
import { Heading, Table } from '@/components'
@@ -72,7 +81,15 @@ export default function TemplateOpenApiContent({ children, ...props }: Component
7281
<div className="mt-1 text-12 text-space-500">{parameter.schema.type}</div>
7382
</td>
7483
<td className="text-body-xsmall">
75-
{parameter.description ? <p className="+:mb-0">{parameter.description}</p> : null}
84+
{parameter.description ? (
85+
<Markdown
86+
rehypePlugins={[rehypeRaw]}
87+
remarkPlugins={[remarkGfm]}
88+
components={{ a: ExperimentalLink as any, code: ExperimentalCodeInline as any }}
89+
>
90+
{parameter.description}
91+
</Markdown>
92+
) : null}
7693
<ul className="mt-1 empty:hidden">
7794
{parameter.schema.default ? (
7895
<li>
@@ -209,7 +226,17 @@ export default function TemplateOpenApiContent({ children, ...props }: Component
209226
{potentialResponse.status}
210227
</ExperimentalTag>
211228
</td>
212-
<td className="text-body-xsmall">{potentialResponse.description}</td>
229+
<td className="text-body-xsmall">
230+
{potentialResponse.description ? (
231+
<Markdown
232+
rehypePlugins={[rehypeRaw]}
233+
remarkPlugins={[remarkGfm]}
234+
components={{ a: ExperimentalLink as any, code: ExperimentalCodeInline as any }}
235+
>
236+
{potentialResponse.description}
237+
</Markdown>
238+
) : null}
239+
</td>
213240
</tr>
214241
)
215242
})}

0 commit comments

Comments
 (0)