a tool for shared writing and social publishing

add titles to tags and profiles

+41
+32
app/(home-pages)/p/[didOrHandle]/layout.tsx
··· 8 8 import { ProfileLayout } from "./ProfileLayout"; 9 9 import { Agent } from "@atproto/api"; 10 10 import { get_profile_data } from "app/api/rpc/[command]/get_profile_data"; 11 + import { Metadata } from "next"; 12 + 13 + export async function generateMetadata(props: { 14 + params: Promise<{ didOrHandle: string }>; 15 + }): Promise<Metadata> { 16 + let params = await props.params; 17 + let didOrHandle = decodeURIComponent(params.didOrHandle); 18 + 19 + let did = didOrHandle; 20 + if (!didOrHandle.startsWith("did:")) { 21 + let resolved = await idResolver.handle.resolve(didOrHandle); 22 + if (!resolved) return { title: "Profile - Leaflet" }; 23 + did = resolved; 24 + } 25 + 26 + let profileData = await get_profile_data.handler( 27 + { didOrHandle: did }, 28 + { supabase: supabaseServerClient }, 29 + ); 30 + let { profile } = profileData.result; 31 + 32 + if (!profile) return { title: "Profile - Leaflet" }; 33 + 34 + const displayName = profile.displayName; 35 + const handle = profile.handle; 36 + 37 + const title = displayName 38 + ? `${displayName} (@${handle}) - Leaflet` 39 + : `@${handle} - Leaflet`; 40 + 41 + return { title }; 42 + } 11 43 12 44 export default async function ProfilePageLayout(props: { 13 45 params: Promise<{ didOrHandle: string }>;
+9
app/(home-pages)/tag/[tag]/page.tsx
··· 3 3 import { PostListing } from "components/PostListing"; 4 4 import { getDocumentsByTag } from "./getDocumentsByTag"; 5 5 import { TagTiny } from "components/Icons/TagTiny"; 6 + import { Metadata } from "next"; 7 + 8 + export async function generateMetadata(props: { 9 + params: Promise<{ tag: string }>; 10 + }): Promise<Metadata> { 11 + const params = await props.params; 12 + const decodedTag = decodeURIComponent(params.tag); 13 + return { title: `${decodedTag} - Leaflet` }; 14 + } 6 15 7 16 export default async function TagPage(props: { 8 17 params: Promise<{ tag: string }>;