From ad8a7daced9ac7b8e58b5eaba92dec05dc90b88d Mon Sep 17 00:00:00 2001 From: Himanshu Sardana Date: Fri, 27 Mar 2026 00:21:02 +0000 Subject: feat: fix toc location for all themes --- themes/tufte/layout.html | 141 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 128 insertions(+), 13 deletions(-) (limited to 'themes/tufte/layout.html') diff --git a/themes/tufte/layout.html b/themes/tufte/layout.html index d5bb93f..3ac212d 100644 --- a/themes/tufte/layout.html +++ b/themes/tufte/layout.html @@ -137,6 +137,8 @@ margin: 2rem auto; } + main { display: flex; flex-direction: column; align-items: center; } + .toc-wrap { margin: 2rem 0; padding: 1rem; @@ -151,23 +153,88 @@ color: #555; margin: 0 0 0.5rem; display: block; + cursor: pointer; } .toc ul { margin: 0; padding-left: 1rem; + list-style: none; + } + + .toc li { + padding: 0.15rem 0; + margin: 0; } + .toc li::before { display: none; } + .toc a { color: #333; text-decoration: none; font-size: 0.95rem; + display: block; + padding: 0.15rem 0; } .toc a:hover { color: #0066cc; } + .toc a.active { + color: #0066cc; + font-weight: 500; + } + + .toc-toggle { + display: flex; + align-items: center; + gap: 0.5rem; + cursor: pointer; + background: none; + border: none; + padding: 0; + font-size: 0.7rem; + letter-spacing: 0.1em; + text-transform: uppercase; + color: #888; + margin-bottom: 0.5rem; + width: 100%; + text-align: left; + } + + .toc-toggle svg { transition: transform 140ms ease; } + .toc-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); } + + .toc-body { + overflow: hidden; + transition: max-height 240ms ease, opacity 200ms ease; + max-height: 500px; + opacity: 1; + } + + .toc-body.collapsed { max-height: 0; opacity: 0; } + + @media (max-width: 699px) { + .toc-title { display: none; } + } + + @media (min-width: 700px) and (max-width: 1099px) { + .toc { display: block; background: transparent; border: none; padding: 0; } + .toc-title { display: block; } + .toc-body { max-height: none !important; opacity: 1 !important; } + } + + @media (min-width: 1100px) { + main { flex-direction: row; align-items: flex-start; max-width: 1100px; } + .toc-wrap { position: sticky; top: 6rem; width: 200px; flex-shrink: 0; margin-right: 3rem; order: -1; background: transparent; padding: 0; } + .toc { background: transparent; border: none; padding: 0; } + .toc-title { display: block; } + .toc-body { max-height: none !important; opacity: 1 !important; } + .article { flex: 1; max-width: 680px; } + main > *:not(.toc-wrap):not(.article) { max-width: 680px; } + } + nav { display: flex; align-items: center; @@ -246,30 +313,78 @@
-
-

{{ .Title }}

-
- {{ if .TOC }}
-
+ +
Contents - +
+ +
{{ end }} -
{{ .Content }}
+
+

{{ .Title }}

+ {{ .Content }} +
+ + \ No newline at end of file -- cgit v1.3.1