Next.js Discord

Discord Forum

meta data not working

Answered
CHEEMDA MAN posted this in #help-forum
Open in Discord
Avatar
export function generateImageMetadata({ params }) {
const { itinerarytype, itineraryname } = params;

// Map itinerary type to JSON key
const itineraryTypeMap = {
"indian-itinerary": "indian",
"foreign-itinerary": "foreign",
};

// Get the correct key for the itinerary type
const jsonKey = itineraryTypeMap[itinerarytype];
const data = jsonKey ? itinerariesData[jsonKey] : null;
// Normalize itinerary name for comparison
const normalizedItineraryName = itineraryname.toUpperCase().trim();
const itinerary = data
? data.find((item) => {
const normalizedTitle = item.title.toUpperCase().trim();
return normalizedTitle.includes(normalizedItineraryName);
})
: null;

const { title, description, image } = itinerary;

return {
title: title,
description: description,
openGraph: {
images: image,
},
}

}


i'm doing this to get meta data but the meta data not appearing is i'm doing something wrong?
Answered by Sun bear
Different problem 😅

You could check this:
https://fabian-rosenthal.com/en/blog/fix-whatsapp-is-not-showing-the-open-graph-image

Maybe image size is the problem
View full answer

8 Replies

Avatar
code of that file in which i'm trying to implement dynamic meta data
Image
Image
Avatar
even this is not working
Image
Avatar
Sun bear
Try generateMetadata instead of generateImageMetadata then it should work
Avatar
thanks bro working now
Avatar
bro working but issue is some apps like on whatsapp the image of meta data not appearing but some apps like discord and telegram the image is appearing
Avatar
Sun bear
Different problem 😅

You could check this:
https://fabian-rosenthal.com/en/blog/fix-whatsapp-is-not-showing-the-open-graph-image

Maybe image size is the problem
Answer
Avatar
ah. okay and thankyou for the reffence of solution too