Display library item's categories on its page

This commit is contained in:
DrMint 2022-03-11 00:32:36 +01:00
parent 252a1af799
commit 1a9f5ae41b
4 changed files with 80 additions and 25 deletions

View File

@ -63,8 +63,7 @@ export default function LibraryItemsPreview(
))} ))}
</div> </div>
{item.release_date || {(item.release_date || item.price) && (
(item.price && (
<div className="grid grid-flow-col w-full"> <div className="grid grid-flow-col w-full">
{item.release_date && ( {item.release_date && (
<p className="mobile:text-xs text-sm"> <p className="mobile:text-xs text-sm">
@ -87,7 +86,7 @@ export default function LibraryItemsPreview(
</p> </p>
)} )}
</div> </div>
))} )}
</div> </div>
</div> </div>
</Link> </Link>

View File

@ -363,6 +363,15 @@ query getLibraryItem($slug: String, $language_code: String) {
} }
} }
} }
categories {
data {
id
attributes {
name
short
}
}
}
size { size {
width width
height height
@ -532,6 +541,15 @@ query getLibraryItem($slug: String, $language_code: String) {
} }
} }
} }
categories {
data {
id
attributes {
name
short
}
}
}
metadata { metadata {
__typename __typename
... on ComponentMetadataBooks { ... on ComponentMetadataBooks {

View File

@ -522,6 +522,18 @@ export type GetLibraryItemQuery = {
}; };
}; };
}; };
categories: {
__typename: "CategoryRelationResponseCollection";
data: Array<{
__typename: "CategoryEntity";
id: string;
attributes: {
__typename: "Category";
name: string;
short: string;
};
}>;
};
size: { size: {
__typename: "ComponentBasicsSize"; __typename: "ComponentBasicsSize";
width: number; width: number;
@ -738,6 +750,18 @@ export type GetLibraryItemQuery = {
}; };
}; };
}; };
categories: {
__typename: "CategoryRelationResponseCollection";
data: Array<{
__typename: "CategoryEntity";
id: string;
attributes: {
__typename: "Category";
name: string;
short: string;
};
}>;
};
metadata: Array< metadata: Array<
| { | {
__typename: "ComponentMetadataAudio"; __typename: "ComponentMetadataAudio";

View File

@ -216,6 +216,20 @@ export default function LibrarySlug(props: LibrarySlugProps): JSX.Element {
</div> </div>
)} )}
</div> </div>
{item.categories.data.length > 0 && (
<div>
<h3 className="text-xl">{langui.categories}</h3>
<div className="flex flex-row flex-wrap place-items-center place-content-start gap-2">
{item.categories.data.map((category) => (
<Chip key={category.id}>
{category.attributes.short}
</Chip>
))}
</div>
</div>
)}
{item.size && ( {item.size && (
<> <>
<h3 className="text-xl">{langui.size}</h3> <h3 className="text-xl">{langui.size}</h3>