diff --git a/frontend/src/pages/profile/layout.tsx b/frontend/src/pages/profile/layout.tsx
index 2847fe2..a2c4987 100644
--- a/frontend/src/pages/profile/layout.tsx
+++ b/frontend/src/pages/profile/layout.tsx
@@ -13,10 +13,10 @@ export default function ProfileLayout() {
const [loading, setLoading] = useState(true);
const $session = useStore(session);
+ const userId = Number($session ? id : $session?.user?.id);
+
useEffect(() => {
if ($session === undefined) return; // session still loading
-
- const userId = id ?? $session?.user?.id;
if (!userId) {
navigate("/404");
return;
@@ -44,14 +44,38 @@ export default function ProfileLayout() {
return
Loading...
;
}
- const sessionUserId = $session?.user?.id ? Number($session.user.id) : null;
- const page = location.pathname;
- const isAdmin = sessionUserId === Number(import.meta.env.VITE_ADMIN_USER_ID);
+ const isAdmin = userId === Number(import.meta.env.VITE_ADMIN_USER_ID);
const isContributor = import.meta.env.VITE_CONTRIBUTORS_USER_IDS?.split(",").includes(String(user?.id));
- const isOwnProfile = sessionUserId === user?.id;
+ const isOwnProfile = userId === user?.id;
+
+ const joinDate = new Date(user.createdAt).toLocaleDateString("en-US", { month: "long", year: "numeric" });
+ const metaTitle = `${user.name} - TomodachiShare`;
+ const metaDescription = `View ${user.name}'s profile on TomodachiShare. Creator of ${user._count.miis} Miis. Member since ${joinDate}.`;
+ const metaImage = user.image.startsWith("/profile")
+ ? `${import.meta.env.VITE_API_URL}${user.image}`
+ : (user.image ?? `${import.meta.env.VITE_API_URL}/guest.png`);
return (
+
{metaTitle}
+
+
+
+
+ {/* Open Graph */}
+
+
+
+
+
+
+ {/* Twitter / X */}
+
+
+
+
+
+
{/* Profile picture */}
@@ -110,19 +134,19 @@ export default function ProfileLayout() {
Admin
)}
- {isOwnProfile && page !== "/profile/likes" && (
+ {isOwnProfile && location.pathname !== "/profile/likes" && (
My Likes
)}
- {isOwnProfile && page !== "/profile/settings" && (
+ {isOwnProfile && location.pathname !== "/profile/settings" && (
Settings
)}
- {(page === "/profile/likes" || page === "/profile/settings") && (
+ {(location.pathname === "/profile/likes" || location.pathname === "/profile/settings") && (
Back