The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Adding the link creator information to the single link page
Marcus Farrellbadfe1ae186a
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsxindex 00fc4ddf4c..a85ccd0a4d 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/links/[...link]/page-client.tsx@@ -36,12 +36,14 @@ import {useCopyToClipboard,useKeyboardShortcut,useMediaQuery,+ Avatar,} from "@dub/ui";-import { cn } from "@dub/utils";+import { cn, timeAgo } from "@dub/utils";import { notFound, useParams, useRouter } from "next/navigation";import { memo, useEffect, useRef, useState } from "react";import { useFormContext, useFormState } from "react-hook-form";import { toast } from "sonner";+import { UserAvatar } from "@/ui/links/link-title-column";export function LinkPageClient() {const params = useParams<{ link: string | string[] }>();@@ -241,14 +243,18 @@ function LinkBuilder({ link }: { link: ExpandedLinkProps }) {<LinkPartnerDetails link={link} partner={partner} /></div>)}++ {/* Creator info at the bottom (desktop only) */}+ {link.user && (+ <div className="mt-2 border-t border-neutral-200 pt-6 hidden lg:flex items-center gap-1 text-sm text-neutral-600">+ <UserAvatar link={link as any} />+ <span>Created by</span>+ <span className="font-semibold text-neutral-800">{link.user.name || link.user.email || "Anonymous"}</span>+ <span className="text-neutral-400">· {timeAgo(link.createdAt)}</span>+ </div>+ )}</div>- {isDesktop && (- <>- <div className="grow" />- <LinkActionBar />- </>- )}</div><div className="px-4 md:px-6 lg:bg-neutral-50 lg:px-0"><div className="mx-auto max-w-xl divide-neutral-200 lg:divide-y">@@ -261,6 +267,15 @@ function LinkBuilder({ link }: { link: ExpandedLinkProps }) {<div className="py-4 lg:px-4 lg:py-6"><LinkPreview /></div>+ {/* Creator info below preview (mobile only) */}+ {link.user && (+ <div className="mt-2 border-t border-neutral-200 pt-6 pb-8 flex lg:hidden items-center gap-1 text-sm text-neutral-600">+ <UserAvatar link={link as any} />+ <span>Created by</span>+ <span className="font-semibold text-neutral-800">{link.user.name || link.user.email || "Anonymous"}</span>+ <span className="text-neutral-400">· {timeAgo(link.createdAt)}</span>+ </div>+ )}</div></div>{!isDesktop && (diff --git a/apps/web/lib/api/links/get-link-or-throw.ts b/apps/web/lib/api/links/get-link-or-throw.tsindex a492caeec5..0c4f3376c9 100644--- a/apps/web/lib/api/links/get-link-or-throw.ts+++ b/apps/web/lib/api/links/get-link-or-throw.ts@@ -48,6 +48,7 @@ export const getLinkOrThrow = async (params: GetLinkParams) => {},include: {webhooks: includeWebhooks,+ user: true,},});}@@ -68,6 +69,7 @@ export const getLinkOrThrow = async (params: GetLinkParams) => {},include: {webhooks: includeWebhooks,+ user: true,},});}diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex 1d461a4717..927988f0ac 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -84,6 +84,7 @@ export interface ExpandedLinkProps extends LinkProps {tags: TagProps[];webhookIds: string[];dashboardId: string | null;+ user?: UserProps;}export interface SimpleLinkProps {diff --git a/apps/web/ui/links/link-title-column.tsx b/apps/web/ui/links/link-title-column.tsxindex ba48d8c165..0dbaccd1c7 100644--- a/apps/web/ui/links/link-title-column.tsx+++ b/apps/web/ui/links/link-title-column.tsx@@ -392,7 +392,7 @@ const Details = memo(},);-function UserAvatar({ link }: { link: ResponseLink }) {+export function UserAvatar({ link }: { link: ResponseLink }) {const { user } = link;const { slug } = useWorkspace();