From dc1b200662469182b097224bbaec799f944d1c74 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 29 Apr 2022 21:55:36 +0800 Subject: [PATCH] fix(theme-common): allow details to not provide a summary --- .../src/theme/MDXComponents/Details.tsx | 5 ++--- .../docusaurus-theme-common/src/components/Details/index.tsx | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/MDXComponents/Details.tsx b/packages/docusaurus-theme-classic/src/theme/MDXComponents/Details.tsx index d09f2d923f634..8ae874a7a23e3 100644 --- a/packages/docusaurus-theme-classic/src/theme/MDXComponents/Details.tsx +++ b/packages/docusaurus-theme-classic/src/theme/MDXComponents/Details.tsx @@ -13,9 +13,8 @@ export default function MDXDetails(props: Props): JSX.Element { const items = React.Children.toArray(props.children) as ReactElement[]; // Split summary item from the rest to pass it as a separate prop to the // Details theme component - const summary: ReactElement> = items.find( - (item) => item?.props?.mdxType === 'summary', - )!; + const summary: ReactElement> | undefined = + items.find((item) => item?.props?.mdxType === 'summary'); const children = <>{items.filter((item) => item !== summary)}; return ( diff --git a/packages/docusaurus-theme-common/src/components/Details/index.tsx b/packages/docusaurus-theme-common/src/components/Details/index.tsx index 1f330edec9a79..5288622062017 100644 --- a/packages/docusaurus-theme-common/src/components/Details/index.tsx +++ b/packages/docusaurus-theme-common/src/components/Details/index.tsx @@ -91,7 +91,7 @@ export function Details({ // setOpen(false); } }}> - {summary} + {summary || Details}