Update getContentItems to return total count and items

The changes involved modifying the implementation of `getContentItems` across multiple files, specifically in the CMS-related codebase. This method now returns an object containing the total count of items and the items themselves. The updates also included necessary adjustments in the code where `getContentItems` is called to accommodate the new structure of the returned result.
This commit is contained in:
giancarlo
2024-04-10 16:29:19 +08:00
parent 44373c0372
commit f94557e333
8 changed files with 89 additions and 71 deletions

View File

@@ -5,12 +5,10 @@ import { DocsNavigation } from '~/(marketing)/docs/_components/docs-navigation';
async function DocsLayout({ children }: React.PropsWithChildren) {
const cms = await createCmsClient();
const pages = await cms.getContentItems({
const { items: pages } = await cms.getContentItems({
collection: 'documentation',
});
console.log(pages);
return (
<div className={'flex'}>
<DocsNavigation pages={buildDocumentationTree(pages)} />

View File

@@ -18,12 +18,12 @@ async function DocsPage() {
const client = await createCmsClient();
const { t } = await createI18nServerInstance();
const docs = await client.getContentItems({
const { items } = await client.getContentItems({
collection: 'documentation',
});
// Filter out any docs that have a parentId, as these are children of other docs
const cards = docs.filter((item) => !item.parentId);
const cards = items.filter((item) => !item.parentId);
return (
<PageBody>
@@ -33,7 +33,7 @@ async function DocsPage() {
subtitle={t('marketing:documentationSubtitle')}
/>
<div className={'flex flex-col items-center'}>
<div className={'container mx-auto flex flex-col items-center'}>
<DocsCards cards={cards} />
</div>
</div>