From 964cdc7d316501725d7af0f32e366bd0294619b0 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 10 Nov 2025 23:21:21 -0500 Subject: [PATCH 1/3] fix: update styling --- public/styles/graph.css | 3 +- public/styles/posts.css | 42 +++++++++- src/components/TableOfContents.astro | 78 +++++++++++++++++++ .../algorithms/models-of-production.mdx | 1 + src/content/config.ts | 1 + src/layouts/PostLayout.astro | 43 +++++++--- src/pages/[category]/[slug].astro | 4 +- 7 files changed, 158 insertions(+), 14 deletions(-) create mode 100644 src/components/TableOfContents.astro diff --git a/public/styles/graph.css b/public/styles/graph.css index 7dc16ab..a4aae9e 100644 --- a/public/styles/graph.css +++ b/public/styles/graph.css @@ -96,7 +96,8 @@ #romer-table th, #romer-table td { - border: 1px solid var(--border); + border: 1px solid var(--text); + background: var(--bg); text-align: center; padding: 5px; } diff --git a/public/styles/posts.css b/public/styles/posts.css index d5c8afc..0e89316 100644 --- a/public/styles/posts.css +++ b/public/styles/posts.css @@ -2,12 +2,28 @@ li { margin: 5px 0; } +.post-wrapper { + display: flex; + width: 100%; + justify-content: center; + align-items: flex-start; + position: relative; +} + +.toc-column { + position: absolute; + left: calc(50% - 400px - 4rem - 200px); + width: 200px; + padding-top: 190px; +} + .post-header { padding: 0; } .post-container { - width: 80%; + width: 65%; + max-width: 800px; } .post-title { @@ -143,6 +159,26 @@ article pre { font-size: 0.8em !important; } +@media (max-width: 1200px) { + .post-wrapper { + grid-template-columns: 1fr; + padding: 0 2rem; + } + + .toc-column { + grid-column: 1; + justify-self: center; + width: 100%; + max-width: 800px; + padding-top: 0; + } + + .post-container { + grid-column: 1; + width: 100%; + } +} + @media (max-width: 768px) { .post-title { font-size: 3em; @@ -155,4 +191,8 @@ article pre { .post-article { font-size: 1.3em; } + + .post-container { + width: 90%; + } } diff --git a/src/components/TableOfContents.astro b/src/components/TableOfContents.astro new file mode 100644 index 0000000..b2e97ee --- /dev/null +++ b/src/components/TableOfContents.astro @@ -0,0 +1,78 @@ +--- +// 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 && ( + + ) +} + + diff --git a/src/content/algorithms/models-of-production.mdx b/src/content/algorithms/models-of-production.mdx index 8383a15..a56376d 100644 --- a/src/content/algorithms/models-of-production.mdx +++ b/src/content/algorithms/models-of-production.mdx @@ -4,6 +4,7 @@ date: "22/06/2024" useKatex: true useD3: true scripts: ["/scripts/models-of-production.js"] +showToc: true --- This post offers a basic introduction to the Solow, Romer, and Romer-Solow economic models, as taught by [Vladimir Smirnyagin](https://www.vladimirsmirnyagin.com/) and assisted by [Donghyun Suh](https://www.donghyunsuh.com/) in Intermediate Macroeconomics (ECON 3020) during the Spring semester of 2024 at the University of Virginia. diff --git a/src/content/config.ts b/src/content/config.ts index 9d4d776..8c455d0 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -8,6 +8,7 @@ const base = z.object({ useD3: z.boolean().optional(), scripts: z.array(z.string()).optional(), redirect: z.string().optional(), + showToc: z.boolean().optional(), }); export const collections = { diff --git a/src/layouts/PostLayout.astro b/src/layouts/PostLayout.astro index 37af82e..863cc53 100644 --- a/src/layouts/PostLayout.astro +++ b/src/layouts/PostLayout.astro @@ -1,6 +1,7 @@ --- import BaseLayout from "./BaseLayout.astro"; import { getTopicColor } from "../utils/colors.js"; +import TableOfContents from "../components/TableOfContents.astro"; interface Props { frontmatter: { @@ -11,16 +12,28 @@ interface Props { useD3?: boolean; scripts?: string[]; category?: string; + showToc?: boolean; }; post?: { id?: string; collection?: string; slug?: string; }; + headings?: Array<{ + depth: number; + slug: string; + text: string; + }>; } -const { frontmatter, post } = Astro.props as Props; -const { title, description, useKatex = false, useD3 = false } = frontmatter; +const { frontmatter, post, headings = [] } = Astro.props as Props; +const { + title, + description, + useKatex = false, + useD3 = false, + showToc = false, +} = frontmatter; let documentTitle = title; if (post?.collection === "git" && post?.slug) { @@ -54,17 +67,27 @@ const topicColor = getTopicColor(post?.collection);
-
-

{title}

- {frontmatter.date && } -
+ { + showToc && headings.length > 0 && ( + + ) + } -
- -
+
+
+

{title}

+ {frontmatter.date && } +
+ +
+ +
+
diff --git a/src/pages/[category]/[slug].astro b/src/pages/[category]/[slug].astro index cc19a00..e9bbec2 100644 --- a/src/pages/[category]/[slug].astro +++ b/src/pages/[category]/[slug].astro @@ -32,7 +32,7 @@ interface Props { const { post } = Astro.props; const category = Astro.params.category; -const { Content } = await post.render(); +const { Content, headings } = await post.render(); const pageTitle = `${category}/${post.data.title ?? post.slug}`; if (post.data?.redirect) { @@ -40,7 +40,7 @@ if (post.data?.redirect) { } --- - + {pageTitle} From a52dfa653fbaec3dc38a433a6ee79c1a0c9669db Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 10 Nov 2025 23:27:32 -0500 Subject: [PATCH 2/3] feat: update --- public/styles/posts.css | 14 ++------------ src/content/algorithms/leetcode-daily.mdx | 1 + 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/public/styles/posts.css b/public/styles/posts.css index 0e89316..09a516e 100644 --- a/public/styles/posts.css +++ b/public/styles/posts.css @@ -160,22 +160,12 @@ article pre { } @media (max-width: 1200px) { - .post-wrapper { - grid-template-columns: 1fr; - padding: 0 2rem; - } - .toc-column { - grid-column: 1; - justify-self: center; - width: 100%; - max-width: 800px; - padding-top: 0; + display: none; } .post-container { - grid-column: 1; - width: 100%; + width: 80%; } } diff --git a/src/content/algorithms/leetcode-daily.mdx b/src/content/algorithms/leetcode-daily.mdx index c98c77c..513a7cb 100644 --- a/src/content/algorithms/leetcode-daily.mdx +++ b/src/content/algorithms/leetcode-daily.mdx @@ -2,6 +2,7 @@ title: "leetcode daily" date: "11/9/2024" useKatex: true +showToc: true --- # [count good numbers](https://leetcode.com/problems/count-good-numbers) From 27df9449449f767a1f6470a18314f41179b4a24c Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 10 Nov 2025 23:56:05 -0500 Subject: [PATCH 3/3] styling --- public/styles/common.css | 9 +++++++++ public/styles/index.css | 5 +++-- public/styles/posts.css | 27 ++++++++++++--------------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/public/styles/common.css b/public/styles/common.css index d3e74c4..fa7c8aa 100644 --- a/public/styles/common.css +++ b/public/styles/common.css @@ -217,6 +217,7 @@ footer { display: flex; justify-content: center; flex: 1; + width: 100%; } a { @@ -234,6 +235,14 @@ li { background-size: 3vw 3vw; } +html:has(body.graph-background) { + background-image: + linear-gradient(to right, var(--grid-color) 1px, transparent 1px), + linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px); + background-size: 3vw 3vw; + background-color: var(--bg); +} + .terminal-cursor { display: inline-block; width: 10px; diff --git a/public/styles/index.css b/public/styles/index.css index 638eb5a..ecc8585 100644 --- a/public/styles/index.css +++ b/public/styles/index.css @@ -5,6 +5,7 @@ body { overscroll-behavior: none; height: 100vh; overflow: hidden; + overflow-x: hidden; } .content { @@ -73,12 +74,12 @@ ul { @media (max-width: 768px) { .topics { - font-size: 1.8em; + font-size: 2em; padding: 0 20px; } .posts { - font-size: 1.8em; + font-size: 1.47em; padding: 0 20px; } diff --git a/public/styles/posts.css b/public/styles/posts.css index 09a516e..d3c16ef 100644 --- a/public/styles/posts.css +++ b/public/styles/posts.css @@ -3,16 +3,14 @@ li { } .post-wrapper { - display: flex; width: 100%; - justify-content: center; - align-items: flex-start; position: relative; } .toc-column { position: absolute; - left: calc(50% - 400px - 4rem - 200px); + left: 2rem; + top: 0; width: 200px; padding-top: 190px; } @@ -24,6 +22,7 @@ li { .post-container { width: 65%; max-width: 800px; + margin: 0 auto; } .post-title { @@ -163,26 +162,24 @@ article pre { .toc-column { display: none; } - - .post-container { - width: 80%; - } } @media (max-width: 768px) { + .post-container { + width: 85%; + } + .post-title { - font-size: 3em; + font-size: 1.8em; + margin: 30px 0; } .post-meta { - font-size: 1.6em; + font-size: 1.2em; + margin-left: 50px; } .post-article { - font-size: 1.3em; - } - - .post-container { - width: 90%; + font-size: 1.1em; } }