From 40609b3ca563ea7748e147409e7c3e293352db66 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 ++--- .../src/components/Details/index.tsx | 2 +- website/_dogfooding/_pages tests/markdownPageTests.md | 8 ++++++++ 3 files changed, 11 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 d09f2d923f63..8ae874a7a23e 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 1f330edec9a7..528862206201 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} || ![](/4/图片.png) ![](/4/docu.png) + +## Details + +
+ +Details without a summary + +