Complete the code to define a dynamic metadata function in Next.js.
export async function generateMetadata({ params }) {
return {
title: [1]
};
}The generateMetadata function returns an object with a dynamic title using template literals and params.id.
Complete the code to import the correct type for generateMetadata in Next.js.
import type { [1] } from 'next';
The correct type to import for the generateMetadata function is Metadata from Next.js.
Fix the error in the code to correctly return dynamic metadata with async function.
export async function generateMetadata({ params }) {
const title = 'Profile of ' + [1];
return {
title
};
}userId or slug.The dynamic parameter is accessed as params.id to build the title string.
Fill both blanks to create a metadata object with dynamic title and description.
export async function generateMetadata({ params }) {
return {
title: [1],
description: [2]
};
}The title and description use template literals with params.slug for dynamic metadata.
Fill all three blanks to generate metadata with dynamic title, description, and openGraph title.
export async function generateMetadata({ params }) {
return {
title: [1],
description: [2],
openGraph: {
title: [3]
}
};
}The title and openGraph.title share the same dynamic template literal, while description is a different dynamic string.