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

View File

@ -10,7 +10,10 @@ const ExploreModelList: React.FC<Props> = ({ models }) => {
return (
<div className="relative h-full w-full flex-shrink-0">
{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} />)}
</div>
)