From 9e1a219b7d626f88e369a74dbc81eec9a3d921ac Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 19:00:10 +0000 Subject: [PATCH 1/3] Initial plan From 527ca336a72daaf696bca0ca28bbd4316dcda2ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 19:02:47 +0000 Subject: [PATCH 2/3] Add OG image for profile page Agent-Logs-Url: https://github.com/techdiary-dev/techdiary.dev/sessions/cdc0e779-fb92-4eda-9b72-735d6256f052 Co-authored-by: kingRayhan <7611746+kingRayhan@users.noreply.github.com> --- .../(profile-page)/opengraph-image.tsx | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 src/app/[username]/(profile-page)/opengraph-image.tsx diff --git a/src/app/[username]/(profile-page)/opengraph-image.tsx b/src/app/[username]/(profile-page)/opengraph-image.tsx new file mode 100644 index 0000000..40cd97d --- /dev/null +++ b/src/app/[username]/(profile-page)/opengraph-image.tsx @@ -0,0 +1,173 @@ +import { getUserByUsername } from "@/backend/services/user.action"; +import getFileUrl from "@/utils/getFileUrl"; +import { sanitizedUsername } from "@/lib/utils"; +import { ImageResponse } from "next/og"; +import { readFile } from "node:fs/promises"; +import { join } from "node:path"; + +interface ProfilePageProps { + params: Promise<{ + username: string; + }>; +} + +export const size = { + width: 1200, + height: 630, +}; +export const contentType = "image/png"; + +const getFileLocation = async (relativePath: string) => { + const fileData = await readFile(join(process.cwd(), "public", relativePath)); + return Uint8Array.from(fileData).buffer; +}; + +export default async function Image(options: ProfilePageProps) { + const { username } = await options.params; + const sanitized = sanitizedUsername(username); + const profile = await getUserByUsername(sanitized, [ + "name", + "username", + "bio", + "profile_photo", + "designation", + ]); + + const displayName = profile?.name ?? sanitized; + const displayUsername = profile?.username ?? sanitized; + const bio = profile?.bio ?? null; + const designation = profile?.designation ?? null; + const profilePhotoUrl = profile?.profile_photo + ? getFileUrl(profile.profile_photo) + : null; + + return new ImageResponse( + ( +
+ @{displayUsername} +
+ {designation ? ( ++ {designation} +
+ ) : null} + {bio ? ( ++ {bio.length > 120 ? bio.slice(0, 117) + "..." : bio} +
+ ) : null} +Techdiary
+Techdiary
+TechDiary