Skip to content

Commit 8ea6091

Browse files
committed
feat(web): add JSON-LD structured data and optimize sitemap for SEO
- Add JSON-LD SoftwareApplication schema to agent detail pages - Add JSON-LD Organization schema to publisher pages with agent listings - Add JSON-LD CollectionPage schema to store page - Create optimized getCachedAgentsForSitemap() with minimal payload - Fix sitemap to use lightweight query (eliminates ~19MB cache warning) - Update agents-transform tests for AgentRowSlim type
1 parent 2878ecb commit 8ea6091

File tree

6 files changed

+544
-167
lines changed

6 files changed

+544
-167
lines changed

web/src/app/publishers/[id]/agents/[agentId]/[version]/page.tsx

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import db from '@codebuff/internal/db'
22
import * as schema from '@codebuff/internal/db/schema'
3+
import { env } from '@codebuff/common/env'
34
import { and, eq } from 'drizzle-orm'
45
import { Calendar } from 'lucide-react'
56
import Link from 'next/link'
@@ -34,6 +35,7 @@ export async function generateMetadata({ params }: AgentDetailPageProps) {
3435
.select({
3536
data: schema.agentConfig.data,
3637
version: schema.agentConfig.version,
38+
created_at: schema.agentConfig.created_at,
3739
})
3840
.from(schema.agentConfig)
3941
.innerJoin(
@@ -85,6 +87,61 @@ export async function generateMetadata({ params }: AgentDetailPageProps) {
8587
}
8688
}
8789

90+
// JSON-LD structured data for SEO
91+
function AgentJsonLd({
92+
agentName,
93+
agentId,
94+
version,
95+
description,
96+
publisherId,
97+
publisherName,
98+
createdAt,
99+
}: {
100+
agentName: string
101+
agentId: string
102+
version: string
103+
description?: string
104+
publisherId: string
105+
publisherName: string
106+
createdAt: Date
107+
}) {
108+
const jsonLd = {
109+
'@context': 'https://schema.org',
110+
'@type': 'SoftwareApplication',
111+
name: agentName,
112+
applicationCategory: 'DeveloperApplication',
113+
operatingSystem: 'Cross-platform',
114+
softwareVersion: version,
115+
description:
116+
description || `AI agent ${agentName} for code assistance and automation`,
117+
url: `${env.NEXT_PUBLIC_CODEBUFF_APP_URL}/publishers/${publisherId}/agents/${agentId}/${version}`,
118+
datePublished: createdAt.toISOString(),
119+
author: {
120+
'@type': 'Organization',
121+
name: publisherName,
122+
url: `${env.NEXT_PUBLIC_CODEBUFF_APP_URL}/publishers/${publisherId}`,
123+
},
124+
provider: {
125+
'@type': 'Organization',
126+
name: 'Codebuff',
127+
url: env.NEXT_PUBLIC_CODEBUFF_APP_URL,
128+
},
129+
offers: {
130+
'@type': 'Offer',
131+
price: '0',
132+
priceCurrency: 'USD',
133+
availability: 'https://schema.org/InStock',
134+
},
135+
}
136+
137+
return (
138+
<script
139+
type="application/ld+json"
140+
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
141+
/>
142+
)
143+
}
144+
88145
const AgentDetailPage = async ({ params }: AgentDetailPageProps) => {
89146
const { id, agentId, version } = await params
90147
// Get publisher info
@@ -148,7 +205,17 @@ const AgentDetailPage = async ({ params }: AgentDetailPageProps) => {
148205
const fullAgentId = `${id}/${agentId}@${latestVersion}`
149206

150207
return (
151-
<div className="container mx-auto py-6 px-4">
208+
<>
209+
<AgentJsonLd
210+
agentName={agentName}
211+
agentId={agentId}
212+
version={version}
213+
description={agentData.description}
214+
publisherId={id}
215+
publisherName={publisherData.name}
216+
createdAt={new Date(agent[0].created_at)}
217+
/>
218+
<div className="container mx-auto py-6 px-4">
152219
<div className="max-w-4xl mx-auto">
153220
{' '}
154221
{/* Navigation */}
@@ -332,6 +399,7 @@ const AgentDetailPage = async ({ params }: AgentDetailPageProps) => {
332399
</div>
333400
</div>
334401
</div>
402+
</>
335403
)
336404
}
337405

0 commit comments

Comments
 (0)