diff --git a/src/theme/DocCard/index.js b/src/theme/DocCard/index.js
index e9fe31e..0fb77c4 100644
--- a/src/theme/DocCard/index.js
+++ b/src/theme/DocCard/index.js
@@ -2,97 +2,103 @@ import React from 'react';
import clsx from 'clsx';
import Link from '@docusaurus/Link';
import {
- useDocById,
- findFirstSidebarItemLink,
+ useDocById,
+ findFirstSidebarItemLink,
} from '@docusaurus/plugin-content-docs/client';
-import {usePluralForm} from '@docusaurus/theme-common';
+import { usePluralForm } from '@docusaurus/theme-common';
import isInternalUrl from '@docusaurus/isInternalUrl';
-import {translate} from '@docusaurus/Translate';
+import { translate } from '@docusaurus/Translate';
import Heading from '@theme/Heading';
import styles from './styles.module.css';
function useCategoryItemsPlural() {
- const {selectMessage} = usePluralForm();
- return (count) =>
- selectMessage(
- count,
- translate(
- {
- message: '1 item|{count} items',
- id: 'theme.docs.DocCard.categoryDescription.plurals',
- description:
- 'The default description for a category card in the generated index about how many items this category includes',
- },
- {count},
- ),
+ const { selectMessage } = usePluralForm();
+ return (count) =>
+ selectMessage(
+ count,
+ translate(
+ {
+ message: '1 item|{count} items',
+ id: 'theme.docs.DocCard.categoryDescription.plurals',
+ description:
+ 'The default description for a category card in the generated index about how many items this category includes',
+ },
+ { count },
+ ),
+ );
+}
+function CardContainer({ className, href, children }) {
+ return (
+
+ {children}
+
);
}
-function CardContainer({className, href, children}) {
- return (
-
- {children}
-
- );
+function CardLayout({ className, href, icon, title, description }) {
+ return (
+
+
+ {icon} {title}
+
+ {description && (
+
+ {description}
+
+ )}
+
+ );
}
-function CardLayout({className, href, icon, title, description}) {
- return (
-
-
- {icon} {title}
-
- {description && (
-
- {description}
-
- )}
-
- );
+function CardCategory({ item }) {
+ const href = findFirstSidebarItemLink(item);
+ const categoryItemsPlural = useCategoryItemsPlural();
+ // Unexpected: categories that don't have a link have been filtered upfront
+ if (!href) {
+ return null;
+ }
+ const ReadMeSubfix = href.endsWith('/') ? 'README' : '/README';
+ const docId = href.substring(6) + ReadMeSubfix;
+ let doc;
+ try {
+ doc = useDocById(docId ?? undefined);
+ } catch (e) {
+ doc = null;
+ }
+ return (
+
+ );
}
-function CardCategory({item}) {
- const href = findFirstSidebarItemLink(item);
- const categoryItemsPlural = useCategoryItemsPlural();
- // Unexpected: categories that don't have a link have been filtered upfront
- if (!href) {
- return null;
- }
- const docId = href.substring(6) + 'README';
- const doc = useDocById(docId ?? undefined);
- return (
-
- );
+function CardLink({ item }) {
+ const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
+ const doc = useDocById(item.docId ?? undefined);
+ return (
+
+ );
}
-function CardLink({item}) {
- const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
- const doc = useDocById(item.docId ?? undefined);
- return (
-
- );
-}
-export default function DocCard({item}) {
- switch (item.type) {
- case 'link':
- return ;
- case 'category':
- return ;
- default:
- throw new Error(`unknown item type ${JSON.stringify(item)}`);
- }
+export default function DocCard({ item }) {
+ switch (item.type) {
+ case 'link':
+ return ;
+ case 'category':
+ return ;
+ default:
+ throw new Error(`unknown item type ${JSON.stringify(item)}`);
+ }
}