diff --git a/prisma/schema.prisma b/prisma/schema.prisma index aeb11648..aa11b854 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -281,6 +281,9 @@ model Link { name String @db.VarChar(100) url String @db.VarChar(500) slug String @unique() @db.VarChar(100) + title String? @db.VarChar(500) + description String? @db.VarChar(500) + image String? @db.VarChar(500) userId String? @map("user_id") @db.Uuid teamId String? @map("team_id") @db.Uuid createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6) diff --git a/src/app/(collect)/q/[slug]/route.ts b/src/app/(collect)/q/[slug]/route.ts index 24089bdb..eb0587f1 100644 --- a/src/app/(collect)/q/[slug]/route.ts +++ b/src/app/(collect)/q/[slug]/route.ts @@ -40,6 +40,39 @@ export async function GET(request: Request, { params }: { params: Promise<{ slug } } + const userAgent = request.headers.get('user-agent') || ''; + const isBot = + /facebookexternalhit|twitterbot|linkedinbot|whatsapp|slackbot|discordbot|telegrambot|applebot|bingbot|googlebot/i.test( + userAgent, + ); + const l = link; + if (isBot && (l.title || l.description || l.image)) { + return new Response( + ` + + + + + + + + + + + + + + + + `, + { + headers: { + 'content-type': 'text/html', + }, + }, + ); + } + const payload = { type: 'event', payload: { diff --git a/src/app/(main)/links/LinkEditForm.tsx b/src/app/(main)/links/LinkEditForm.tsx index 6c10c7f0..bd1ffa8d 100644 --- a/src/app/(main)/links/LinkEditForm.tsx +++ b/src/app/(main)/links/LinkEditForm.tsx @@ -101,26 +101,28 @@ export function LinkEditForm({ - - + + + + + + + + + + - + > + +