From c16375ca9033971919e0d6f36727377d1fdc1cc4 Mon Sep 17 00:00:00 2001 From: Jason Antwi-Appah Date: Sat, 29 Jun 2024 19:15:59 -0500 Subject: [PATCH] Implement table of contents on markdown layout --- src/components/home/division.astro | 4 +- src/components/home/summary.astro | 8 +- src/layouts/markdown.astro | 126 ++++++++++++++++++----------- src/pages/about.mdx | 2 +- 4 files changed, 82 insertions(+), 58 deletions(-) diff --git a/src/components/home/division.astro b/src/components/home/division.astro index ff2c69b..15f8f93 100644 --- a/src/components/home/division.astro +++ b/src/components/home/division.astro @@ -73,12 +73,12 @@ const {
{ images.map((img) => ( diff --git a/src/components/home/summary.astro b/src/components/home/summary.astro index 2e56551..fb4c182 100644 --- a/src/components/home/summary.astro +++ b/src/components/home/summary.astro @@ -1,5 +1,5 @@
-
+

We are a group of students who are passionate about all things robots - from the mechanical aspects, to writing software, and all the things in between.


-

- Our goal is to promote robotics at UT Dallas and in the surrounding area through outreach, projects and workshops. -

-

Every Monday* at 7pm, we meet to learn and build all sorts of robots - for fun, and to compete in a variety of events.

diff --git a/src/layouts/markdown.astro b/src/layouts/markdown.astro index a7b1305..e0a626d 100644 --- a/src/layouts/markdown.astro +++ b/src/layouts/markdown.astro @@ -15,14 +15,13 @@ type Props = MarkdownLayoutProps<{ const { title, subtitle } = Astro.props.frontmatter || Astro.props; -const toc = Astro.props.headings.filter(h=>h.depth == 1) +const toc = Astro.props.headings.filter(h=>h.depth <= 2) const renderTOC = toc.length > 1 -// TODO: TOC ---
1 {subtitle}
-
- - - -
+ } + } + +
+ {renderTOC &&
    + {toc.map(entry=>( +
  1. + + {entry.text} + +
  2. + ))} +
} +
+ + + +
+
diff --git a/src/pages/about.mdx b/src/pages/about.mdx index 3437735..2dec11b 100644 --- a/src/pages/about.mdx +++ b/src/pages/about.mdx @@ -3,7 +3,7 @@ layout: ../layouts/markdown.astro title: About subtitle: More about the club and its history --- -import {leadership} from '../data' +import { leadership } from '../data' # Who we are