remove toc
This commit is contained in:
parent
a19b417d71
commit
f3aeeb1b5f
8 changed files with 177 additions and 282 deletions
|
|
@ -1,80 +0,0 @@
|
|||
---
|
||||
// Auto-generated TOC from MDX headings - Left sidebar
|
||||
interface Props {
|
||||
headings: Array<{
|
||||
depth: number;
|
||||
slug: string;
|
||||
text: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
const { headings } = Astro.props;
|
||||
|
||||
// Filter to only show h1 and h2
|
||||
const tocHeadings = headings.filter((h) => h.depth <= 2);
|
||||
---
|
||||
|
||||
{
|
||||
tocHeadings.length > 0 && (
|
||||
<aside class="toc-sidebar">
|
||||
<div class="toc-title">contents</div>
|
||||
<nav class="toc-nav">
|
||||
{tocHeadings.map((heading) => (
|
||||
<a
|
||||
href={`#${heading.slug}`}
|
||||
class={heading.depth === 1 ? "h1-link" : "h2-link"}
|
||||
>
|
||||
{heading.text}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
|
||||
<style>
|
||||
.toc-sidebar {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.toc-title {
|
||||
font-weight: normal;
|
||||
margin-bottom: 1rem;
|
||||
text-align: left;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.toc-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.3rem;
|
||||
align-items: flex-start;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.toc-nav a {
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
line-height: 1.4;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.toc-nav a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.toc-nav a.h1-link {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.toc-nav a.h2-link {
|
||||
padding-left: 1.5rem;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.toc-sidebar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue