import Link from "next/link"; import { GetContentsQuery } from "graphql/operations-types"; import { prettySlug } from "queries/helpers"; import Chip from "components/Chip"; import Img, { ImageQuality } from "components/Img"; export type LibraryContentPreviewProps = { item: { slug: GetContentsQuery["contents"]["data"][number]["attributes"]["slug"]; thumbnail: GetContentsQuery["contents"]["data"][number]["attributes"]["thumbnail"]; titles: GetContentsQuery["contents"]["data"][number]["attributes"]["titles"]; categories: GetContentsQuery["contents"]["data"][number]["attributes"]["categories"]; type: GetContentsQuery["contents"]["data"][number]["attributes"]["type"]; }; }; export default function LibraryContentPreview( props: LibraryContentPreviewProps ): JSX.Element { const item = props.item; return (
{item.thumbnail.data ? ( ) : (
)}
{item.type ? ( {item.type.data.attributes.titles.length > 0 ? item.type.data.attributes.titles[0].title : prettySlug(item.type.data.attributes.slug)} ) : ( "" )}
{item.titles.length > 0 ? ( <>

{item.titles[0].pre_title}

{item.titles[0].title}

{item.titles[0].subtitle}

) : (

{prettySlug(item.slug)}

)}
{item.categories.data.map((category) => ( {category.attributes.short} ))}
); }