Skip to content

Commit d7f8454

Browse files
fix(theme): render code tag in Response placeholder message (#1299)
Replace translate() function with Translate component using JSX interpolation to properly render the <code> element in the Response placeholder message instead of displaying it as raw text. Fixes #1298 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0a89b9d commit d7f8454

File tree

1 file changed

+32
-12
lines changed
  • packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Response

1 file changed

+32
-12
lines changed

packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Response/index.tsx

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import React from "react";
99

1010
import { useDoc } from "@docusaurus/plugin-content-docs/client";
1111
import { usePrismTheme } from "@docusaurus/theme-common";
12-
import { translate } from "@docusaurus/Translate";
12+
import Translate, { translate } from "@docusaurus/Translate";
1313
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
1414
import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
1515
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
1616
import SchemaTabs from "@theme/SchemaTabs";
1717
import TabItem from "@theme/TabItem";
18-
import { OPENAPI_RESPONSE } from "@theme/translationIds";
18+
import { OPENAPI_REQUEST, OPENAPI_RESPONSE } from "@theme/translationIds";
1919
import clsx from "clsx";
2020
import type { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
2121
import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
@@ -126,11 +126,22 @@ function Response({ item }: { item: ApiItem }) {
126126
>
127127
{prettyResponse || (
128128
<p className="openapi-explorer__response-placeholder-message">
129-
{translate({
130-
id: OPENAPI_RESPONSE.PLACEHOLDER,
131-
message:
132-
"Click the <code>Send API Request</code> button above and see the response here!",
133-
})}
129+
<Translate
130+
id={OPENAPI_RESPONSE.PLACEHOLDER}
131+
values={{
132+
code: (
133+
<code>
134+
<Translate id={OPENAPI_REQUEST.SEND_BUTTON}>
135+
Send API Request
136+
</Translate>
137+
</code>
138+
),
139+
}}
140+
>
141+
{
142+
"Click the {code} button above and see the response here!"
143+
}
144+
</Translate>
134145
</p>
135146
)}
136147
</ApiCodeBlock>
@@ -163,11 +174,20 @@ function Response({ item }: { item: ApiItem }) {
163174
</div>
164175
) : (
165176
<p className="openapi-explorer__response-placeholder-message">
166-
{translate({
167-
id: OPENAPI_RESPONSE.PLACEHOLDER,
168-
message:
169-
"Click the <code>Send API Request</code> button above and see the response here!",
170-
})}
177+
<Translate
178+
id={OPENAPI_RESPONSE.PLACEHOLDER}
179+
values={{
180+
code: (
181+
<code>
182+
<Translate id={OPENAPI_REQUEST.SEND_BUTTON}>
183+
Send API Request
184+
</Translate>
185+
</code>
186+
),
187+
}}
188+
>
189+
{"Click the {code} button above and see the response here!"}
190+
</Translate>
171191
</p>
172192
)}
173193
</div>

0 commit comments

Comments
 (0)