fix(build): build error caused by non-exsisting readme

This commit is contained in:
KirisameVanilla 2025-09-28 10:19:17 +08:00
parent 34c949d43f
commit f2ceda77aa
No known key found for this signature in database
GPG Key ID: A68EE6C617D68238
1 changed files with 89 additions and 83 deletions

View File

@ -61,15 +61,21 @@ function CardCategory({item}) {
if (!href) { if (!href) {
return null; return null;
} }
const docId = href.substring(6) + 'README'; const ReadMeSubfix = href.endsWith('/') ? 'README' : '/README';
const doc = useDocById(docId ?? undefined); const docId = href.substring(6) + ReadMeSubfix;
let doc;
try {
doc = useDocById(docId ?? undefined);
} catch (e) {
doc = null;
}
return ( return (
<CardLayout <CardLayout
className={item.className} className={item.className}
href={href} href={href}
icon="🗃️" icon="🗃️"
title={item.label} title={item.label}
description={item.description ?? doc.description ?? categoryItemsPlural(item.items.length)} description={item.description ?? doc?.description ?? categoryItemsPlural(item.items.length)}
/> />
); );
} }