Skip to content

Commit

Permalink
fix(theme-common): allow details to not provide a summary
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Apr 29, 2022
1 parent ae788c5 commit dc1b200
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc1b200

Please sign in to comment.