如何在 next js 13 中使用开放图元标记?
P粉768045522
P粉768045522 2023-11-10 23:03:51

在最近的 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 
};

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

P粉768045522
P粉768045522

全部回复(1)
P粉709644700

元数据对象的一部分专用于 OpenGraph 的元数据。

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

简短的版本是这样的:

export const metadata = {
  openGraph: {
    title: 'this is open graph title for testing',
    description: 'Some description',
  }
};

我还希望您需要根据路径、搜索参数和查询动态生成此类数据。如果是这样,请使用导出异步函数generateMetadata(…)而不是导出const元数据相关文档有很大帮助。 p>

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!