mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-19 17:49:19 +02:00
fix(theme-common): allow details to not provide a summary (#7267)
This commit is contained in:
parent
e053f39cf0
commit
41f53718c1
3 changed files with 11 additions and 4 deletions
|
@ -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<ComponentProps<'summary'>> = items.find(
|
||||
(item) => item?.props?.mdxType === 'summary',
|
||||
)!;
|
||||
const summary: ReactElement<ComponentProps<'summary'>> | undefined =
|
||||
items.find((item) => item?.props?.mdxType === 'summary');
|
||||
const children = <>{items.filter((item) => item !== summary)}</>;
|
||||
|
||||
return (
|
||||
|
|
|
@ -91,7 +91,7 @@ export function Details({
|
|||
// setOpen(false);
|
||||
}
|
||||
}}>
|
||||
{summary}
|
||||
{summary || <summary>Details</summary>}
|
||||
|
||||
<Collapsible
|
||||
lazy={false} // Content might matter for SEO in this case
|
||||
|
|
|
@ -175,3 +175,11 @@ Code tag + double pipe: <code>||</code>
|
|||

|
||||
|
||||

|
||||
|
||||
## Details
|
||||
|
||||
<details>
|
||||
|
||||
Details without a summary
|
||||
|
||||
</details>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue