Next.js Discord

Discord Forum

generateMetaData not working

Unanswered
Giant Angora posted this in #help-forum
Open in Discord
Giant AngoraOP
I'm putting generateMetaData for my app and it wont show metadata in embed previewers

9 Replies

Giant AngoraOP
export async function getProfe(handle) {
    const supabase = await createClient();
    const profeRes = await supabase
        .from("profes")
        .select("*")
        .eq("handle", handle)
        .single();

    return profeRes.data;
}

export async function getMetadata(data) {
    const title = data ? `${data.display_name} | Profe` : "Profile not found | Profe";
    const handle = data ? `${data.handle}` : "profe";
    const description = `Meet ${data.display_name || "Me"} On Profe`;
    const url = data ? `https://profe-alpha.vercel.app/${data.handle}` : "https://profe-alpha.vercel.app";
    const image = data ? `${process.env.NEXT_PUBLIC_HOST}/p/${data.handle}/opengraph-image` : "https://cdn.profe.app/default-avatar.png";

    return (
        {title,handle,description,url,image}
    )

}

export async function generateMetadata({ params }) {

    const {profeHandle} = params
    
    const profe = await getProfe(profeHandle)

    const metadata = await getMetadata(profe) 
    
    if (!profe) {
        return {
            title: "Profe not found | Profe",
            description: "This Profe does not exist.",
        }
    }

    return {
        title: metadata.title,
        description: metadata.description,
        openGraph: {
            title: metadata.title,
            description: metadata.description,
            url: metadata.url,
            siteName: "Profe",
            type: "profile",
            images: [
                {
                    url: metadata.image,
                    width: 1200,
                    height: 630
                },
            ],
        },
        twitter: {
            card: "summary_large_image",
            title: metadata.title,
            description: metadata.description,
            images: [metadata.image]
        }
    }

}
When in send route url in Discord , it wont show its embed
Title too , it wont change website title in browsers
Also , i used <head> , it worked , it show tab title , or work in embed previewers , but overall it not work on DIscord
Giant AngoraOP
Here
My home route will send an embed
But when i come for /app/p/[profeHandle]/layout.jsx ( above file ) , it wont send embed with below link