如何在 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學習者快速成長!