feat: update dependencies to k-ap v0.1.7 and add profileHref utility for user links

This commit is contained in:
2026-05-27 23:37:22 +02:00
parent 6f65742284
commit f6893b19dc
18 changed files with 254 additions and 224 deletions

View File

@@ -8,6 +8,7 @@ import { Button } from "@/components/ui/button";
import { UserAvatar } from "@/components/user-avatar";
import { toast } from "sonner";
import { UserPlus } from "lucide-react";
import { profileHref } from "@/lib/utils";
interface RemoteUserCardProps {
actor: {
@@ -18,19 +19,6 @@ interface RemoteUserCardProps {
};
}
function resolveProfileHref(handle: string): string {
const apiDomain = process.env.NEXT_PUBLIC_API_URL
? new URL(process.env.NEXT_PUBLIC_API_URL).hostname
: null;
const clean = handle.startsWith("@") ? handle.slice(1) : handle;
const atIdx = clean.indexOf("@");
const domain = atIdx !== -1 ? clean.slice(atIdx + 1) : null;
const username = atIdx !== -1 ? clean.slice(0, atIdx) : clean;
return apiDomain && domain === apiDomain
? `/users/${username}`
: `/remote-actor?handle=@${clean}`;
}
export function RemoteUserCard({ actor }: RemoteUserCardProps) {
const [followed, setFollowed] = useState(false);
const [loading, setLoading] = useState(false);
@@ -56,7 +44,7 @@ export function RemoteUserCard({ actor }: RemoteUserCardProps) {
return (
<div className="flex items-center justify-between p-4 border rounded-lg">
<Link
href={resolveProfileHref(actor.handle)}
href={profileHref(actor.handle, false)}
className="flex items-center gap-3 hover:opacity-80"
>
<UserAvatar src={actor.avatarUrl} alt={actor.displayName ?? actor.handle} />