diff --git a/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx index de65d3d642..15c8ac155d 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx @@ -22,20 +22,15 @@ function CardContainer({ href, children, }: { - href?: string; + href: string; children: ReactNode; }): JSX.Element { - const className = clsx( - 'card margin-bottom--lg padding--lg', - styles.cardContainer, - href && styles.cardContainerLink, - ); - return href ? ( - + return ( + {children} - ) : ( -
{children}
); } @@ -45,7 +40,7 @@ function CardLayout({ title, description, }: { - href?: string; + href: string; icon: ReactNode; title: string; description?: string; @@ -55,17 +50,29 @@ function CardLayout({

{icon} {title}

-
- {description} -
+ {description && ( +

+ {description} +

+ )} ); } -function CardCategory({item}: {item: PropSidebarItemCategory}): JSX.Element { +function CardCategory({ + item, +}: { + item: PropSidebarItemCategory; +}): JSX.Element | null { const href = findFirstCategoryLink(item); + + // Unexpected: categories that don't have a link have been filtered upfront + if (!href) { + return null; + } + return ( { + if (item.type === 'category') { + return !!findFirstCategoryLink(item); + } + return true; + }); +} export default function DocCardList({ items, @@ -17,9 +28,9 @@ export default function DocCardList({ }): JSX.Element { return (
- {items.map((item, index) => ( -
- + {filterItems(items).map((item, index) => ( +
+
))}