diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/utils.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/utils.ts index f0ffb83b3..c4dfe1663 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/utils.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/utils.ts @@ -5,6 +5,10 @@ * LICENSE file in the root directory of this source tree. * ========================================================================== */ +/** + * Children in the plugin does not accept DOM elements, when compared with Children in the theme. + * It is designed for rendering HTML a strings. + */ export type Children = string | undefined | (string | string[] | undefined)[]; export type Props = Record & { children?: Children }; diff --git a/packages/docusaurus-theme-openapi-docs/src/markdown/utils.ts b/packages/docusaurus-theme-openapi-docs/src/markdown/utils.ts index 1c9539170..b3b53872a 100644 --- a/packages/docusaurus-theme-openapi-docs/src/markdown/utils.ts +++ b/packages/docusaurus-theme-openapi-docs/src/markdown/utils.ts @@ -7,9 +7,10 @@ import { ReactNode } from "react"; -export type Children = ReactNode | string | undefined | (string | undefined)[]; +/** @deprecated use ReactNode from React instead */ +export type Children = ReactNode; -export type Props = Record & { children?: Children }; +export type Props = Record & { children?: ReactNode }; export function create(tag: string, props: Props): string { const { children, ...rest } = props; @@ -24,8 +25,8 @@ export function create(tag: string, props: Props): string { export function guard( value: T | undefined | string, - cb: (value: T) => Children -): string { + cb: (value: T) => ReactNode +) { if (!!value || value === 0) { const children = cb(value as T); return render(children); @@ -33,11 +34,11 @@ export function guard( return ""; } -export function render(children: Children): string { +export function render(children: ReactNode) { if (Array.isArray(children)) { return children.filter((c) => c !== undefined).join(""); } - return (children as string) ?? ""; + return children ?? ""; } export function toString(value: any): string | undefined {