fix: link collections to public URLs on agent page
- Add slug and owner username to collection data in API response - Make collection items clickable links to /@username/collections/slug
This commit is contained in:
parent
64ee34d35f
commit
014da0171e
2 changed files with 16 additions and 2 deletions
|
|
@ -33,9 +33,13 @@ interface AgentCollection {
|
|||
collectionId: string;
|
||||
collection: {
|
||||
id: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
toolCount: number;
|
||||
user: {
|
||||
username: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -345,7 +349,11 @@ export default function PrettyAgentDetailPage(): React.ReactElement {
|
|||
<h2 className="text-lg font-semibold text-foreground mb-4">Collections</h2>
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
{agent.collections.map((ac) => (
|
||||
<div key={ac.id} className="p-4 bg-surface border border-border rounded-lg">
|
||||
<Link
|
||||
key={ac.id}
|
||||
href={`/${ac.collection.user.username}/collections/${ac.collection.slug}`}
|
||||
className="block p-4 bg-surface border border-border rounded-lg hover:border-foreground-secondary transition-colors"
|
||||
>
|
||||
<h3 className="font-medium text-foreground">{ac.collection.name}</h3>
|
||||
{ac.collection.description && (
|
||||
<p className="text-sm text-foreground-secondary mt-1 line-clamp-2">
|
||||
|
|
@ -355,7 +363,7 @@ export default function PrettyAgentDetailPage(): React.ReactElement {
|
|||
<span className="text-xs text-foreground-tertiary mt-2 inline-block">
|
||||
{ac.collection.toolCount} tools
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -62,8 +62,12 @@ export async function GET(_request: NextRequest, context: RouteContext) {
|
|||
collection: {
|
||||
select: {
|
||||
id: true,
|
||||
slug: true,
|
||||
name: true,
|
||||
description: true,
|
||||
user: {
|
||||
select: { username: true },
|
||||
},
|
||||
_count: { select: { tools: true } },
|
||||
},
|
||||
},
|
||||
|
|
@ -128,9 +132,11 @@ export async function GET(_request: NextRequest, context: RouteContext) {
|
|||
collectionId: ac.collectionId,
|
||||
collection: {
|
||||
id: ac.collection.id,
|
||||
slug: ac.collection.slug,
|
||||
name: ac.collection.name,
|
||||
description: ac.collection.description,
|
||||
toolCount: ac.collection._count.tools,
|
||||
user: ac.collection.user,
|
||||
},
|
||||
})),
|
||||
forkedFromId: agent.forkedFromId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue