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/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/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 d5c8afc..d3c16ef 100644 --- a/public/styles/posts.css +++ b/public/styles/posts.css @@ -2,12 +2,27 @@ li { margin: 5px 0; } +.post-wrapper { + width: 100%; + position: relative; +} + +.toc-column { + position: absolute; + left: 2rem; + top: 0; + width: 200px; + padding-top: 190px; +} + .post-header { padding: 0; } .post-container { - width: 80%; + width: 65%; + max-width: 800px; + margin: 0 auto; } .post-title { @@ -143,16 +158,28 @@ article pre { font-size: 0.8em !important; } +@media (max-width: 1200px) { + .toc-column { + display: none; + } +} + @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; + font-size: 1.1em; } } 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/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) 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);