32 lines
763 B
TypeScript
32 lines
763 B
TypeScript
export const layout = "./base.tsx";
|
|
|
|
export default function({ children, toc }) {
|
|
return (
|
|
<>
|
|
{ toc.length > 0 &&
|
|
<nav class="toc">
|
|
<h2>Table of Contents</h2>
|
|
<ol>
|
|
{toc.map(item => (
|
|
<li>
|
|
<a href={`#${item.slug}`}>{item.text}</a>
|
|
{item.children.length > 0 &&
|
|
<ul>
|
|
{item.children.map(child => (
|
|
<li>
|
|
<a href={`#${child.slug}`}>{child.text}</a>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
}
|
|
</li>
|
|
))}
|
|
</ol>
|
|
</nav>
|
|
}
|
|
<article>
|
|
{ children }
|
|
</article>
|
|
</>
|
|
);
|
|
}
|