Skip to content

Commit

Permalink
fix: ToC headings are <li>s, decreased spacing, removed bulletpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
FjellOverflow committed Oct 24, 2024
1 parent a9dd54e commit 0f21229
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/components/ToC.astro
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ while (headings.length) {
function resolveEl(heading: ProcessedHeading) {
let li = `<a href="#${heading.slug}">${heading.text}</a>`
if (heading.children)
li += heading.children
.map((child) => `<ul>${resolveEl(child)}</ul>`)
.join('')
if (heading.children.length) {
li += `<ul>${heading.children
.map((child) => `${resolveEl(child)}`)
.join('')}</ul>`
}
return `<li>${li}</li>`
}
---

<div class="p-4">
<div class="p-4" id="toc">
<Prose>
<h2 class="no-anchor mb-2">Table of Contents</h2>

Expand All @@ -61,3 +62,18 @@ function resolveEl(heading: ProcessedHeading) {
</details>
</Prose>
</div>
<style>
#toc {
ul {
@apply my-1 list-none;
}

li {
@apply my-1;
}

a {
@apply no-underline hover:underline;
}
}
</style>

0 comments on commit 0f21229

Please sign in to comment.