跳到內容
調色盤星雲光譜
選擇版面配色

即時套用,保留目前的亮暗模式。

TableOfContents (am-table-of-contents)

TableOfContents 將 consumer 已知的文章標題轉成伺服器輸出的頁內連結。它不掃描文件、不產生標題 ID,也不需要瀏覽器腳本。

  • items 必須提供標籤與對應的頁內 href,例如 #overview
  • level: 3 會縮排顯示;其他值以第二層標題呈現
  • 清單為空時不輸出導覽區塊
  • items 的 href 必須對應 consumer 輸出的標題 ID
  • title 預設為 On this page;ariaLabel 預設沿用標題
<TableOfContents
items={[
{ label: "Overview", href: "#overview", level: 2 },
{ label: "Details", href: "#details", level: 3 },
]}
/>
<h2 id="overview">Overview</h2>
<h3 id="details">Details</h3>

Heading IDs and labels remain owned by the content source. The component does not determine which section is currently visible.