2024-04-23 15:16:51 +00:00
|
|
|
---
|
|
|
|
// github.com/rezahedi/rezahedi.dev/blob/main/src/components/TOCHeading.astro
|
2024-08-26 14:36:52 +00:00
|
|
|
const { heading, parentMono } = Astro.props;
|
|
|
|
|
|
|
|
// If a heading starts with `API: `
|
|
|
|
// then its children should be rendered with a mono font
|
|
|
|
const isMono = heading.text.startsWith("API: ");
|
|
|
|
const monoClass = parentMono? " font-mono" : "";
|
2024-04-23 15:16:51 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
<li>
|
2024-08-26 14:36:52 +00:00
|
|
|
<a class={"inline-block py-1 hover:underline" + monoClass} href={"#" + heading.slug}>
|
2024-04-23 15:16:51 +00:00
|
|
|
{heading.text}
|
|
|
|
</a>
|
|
|
|
{
|
|
|
|
heading.subheadings.length > 0 && (
|
|
|
|
<ul class="px-2">
|
|
|
|
{heading.subheadings.map((subheading: any) => (
|
2024-08-26 14:36:52 +00:00
|
|
|
<Astro.self heading={subheading} parentMono={isMono} />
|
2024-04-23 15:16:51 +00:00
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</li>
|