Skip to content

Commit

Permalink
fix collections
Browse files Browse the repository at this point in the history
  • Loading branch information
olexh committed Apr 1, 2024
1 parent 7baffad commit 9c49777
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ interface Props {
}

const CollectionItem = ({ collection }: Props) => {
const poster = (content: API.Anime | API.Character | API.Person) =>
'poster' in content ? content.poster : content.image;
const title = (content: API.Anime | API.Character | API.Person) =>
'title_ua' in content
? content.title_ua || content.title_en || content.title_ja
: content.name_ua || content.name_en;

return (
<div className="flex flex-col gap-4">
<div className={cn('flex gap-2')}>
Expand Down Expand Up @@ -98,15 +105,12 @@ const CollectionItem = ({ collection }: Props) => {
)}
href={`/anime/${item.content.slug}`}
key={item.content.slug}
poster={item.content.poster}
title={
item.content.title_ua ||
item.content.title_en ||
item.content.title_ja
}
poster={poster(item.content)}
title={title(item.content)}
slug={item.content.slug}
content_type="anime"
content_type={item.content_type}
watch={
'watch' in item.content &&
item.content.watch.length > 0
? item.content.watch[0]
: undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface Props {

const Component = ({ data, className }: Props) => {
const description = parseTextFromMarkDown(data.description);
const poster = (content: API.Anime | API.Character | API.Person) =>
'poster' in content ? content.poster : content.image;

return (
<div className={cn('flex gap-4', className)}>
Expand All @@ -27,7 +29,7 @@ const Component = ({ data, className }: Props) => {
data.nsfw && 'blur-sm hover:blur-none',
)}
href={`/collections/${data.reference}`}
poster={data.collection[0].content.poster}
poster={poster(data.collection[0].content)}
/>
</div>
<div className="flex min-w-0 flex-1 flex-col gap-2">
Expand Down

0 comments on commit 9c49777

Please sign in to comment.