TableOfContents (am-table-of-contents)
TableOfContents 將 consumer 已知的文章標題轉成伺服器輸出的頁內連結。它不掃描文件、不產生標題 ID,也不需要瀏覽器腳本。
Contract
Section titled “Contract”items必須提供標籤與對應的頁內href,例如#overviewlevel: 3會縮排顯示;其他值以第二層標題呈現- 清單為空時不輸出導覽區塊
items的 href 必須對應 consumer 輸出的標題 IDtitle預設為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.