如何在 next js 13 中使用开放图元标记?

Moh*_*ele 6 meta-tags reactjs next.js

在最近的 Next JS 13 更新中,他们引入了一种处理元标记的新方法,该方法与传统方法不同,即创建 Next Head 并编写常用的 html 元标记。在新方法中,我们创建一个类似元数据对象的方法。但我还没有找到使用开放图元数据的方法。

export const metadata = {
  title:
    " this is the title of the web",
  description:
    " this is the description section",
  ogtitle: "this is open graph title for testing", // i thought this could be the case 
};
Run Code Online (Sandbox Code Playgroud)

那么我如何在元数据中使用开放图呢?

Pie*_*mon 11

\xe2\x80\x99s 对象的一部分metadata专用于 OpenGraph\xe2\x80\x99s 元数据。

\n

请参阅相关文档了解更多详细信息。

\n

简短的版本是这样的:

\n
export const metadata = {\n  openGraph: {\n    title: \'this is open graph title for testing\',\n    description: \'Some description\',\n  }\n};\n
Run Code Online (Sandbox Code Playgroud)\n

我还希望您需要根据路径、搜索参数和查询动态生成此类数据。如果是这样,请使用export async function generateMetadata(\xe2\x80\xa6)而不是export const metadata. 相关文档有很大帮助。

\n