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) {
return null;
}
const docId = href.substring(6) + 'README';
const doc = useDocById(docId ?? undefined);
const ReadMeSubfix = href.endsWith('/') ? 'README' : '/README';
const docId = href.substring(6) + ReadMeSubfix;
let doc;
try {
doc = useDocById(docId ?? undefined);
} catch (e) {
doc = null;
}
return (
<CardLayout
className={item.className}
href={href}
icon="🗃️"
title={item.label}
description={item.description ?? doc.description ?? categoryItemsPlural(item.items.length)}
description={item.description ?? doc?.description ?? categoryItemsPlural(item.items.length)}
/>
);
}