Sort by recommended tags

This commit is contained in:
Faisal Amir 2023-12-04 22:17:10 +07:00
parent 860dfea3aa
commit 491f4d7289
2 changed files with 9 additions and 4 deletions

View File

@ -46,13 +46,15 @@ const ExploreModelItem = forwardRef<HTMLDivElement, Props>(({ model }, ref) => {
<span className="font-semibold text-muted-foreground"> <span className="font-semibold text-muted-foreground">
Author Author
</span> </span>
<p className="mt-2 font-medium">{model.metadata.author}</p> <p className="mt-2 line-clamp-1 font-medium">
{model.metadata.author}
</p>
</div> </div>
<div> <div>
<span className="mb-1 font-semibold text-muted-foreground"> <span className="mb-1 font-semibold text-muted-foreground">
Model ID Model ID
</span> </span>
<p className="mt-2 font-medium">{model.id}</p> <p className="mt-2 line-clamp-1 font-medium">{model.id}</p>
</div> </div>
<div> <div>
<span className="mb-1 font-semibold text-muted-foreground"> <span className="mb-1 font-semibold text-muted-foreground">
@ -60,7 +62,7 @@ const ExploreModelItem = forwardRef<HTMLDivElement, Props>(({ model }, ref) => {
</span> </span>
<div className="mt-2 flex space-x-2"> <div className="mt-2 flex space-x-2">
{model.metadata.tags.map((tag, i) => ( {model.metadata.tags.map((tag, i) => (
<Badge key={i} themes="primary"> <Badge key={i} themes="primary" className="line-clamp-1">
{tag} {tag}
</Badge> </Badge>
))} ))}

View File

@ -10,7 +10,10 @@ const ExploreModelList: React.FC<Props> = ({ models }) => {
return ( return (
<div className="relative h-full w-full flex-shrink-0"> <div className="relative h-full w-full flex-shrink-0">
{models {models
?.sort((a, b) => a.metadata.size - b.metadata.size) ?.sort((a) => {
if (a.metadata.tags.includes('Recommended')) return -1
return 0
})
?.map((model) => <ExploreModelItem key={model.id} model={model} />)} ?.map((model) => <ExploreModelItem key={model.id} model={model} />)}
</div> </div>
) )