@@ -30,10 +30,10 @@ const formattedDate = new Date(post.date).toLocaleDateString("en-US", {
3030---
3131
3232{ toc .length > 0 && (
33- <div class = " fixed inset-x-0 top-14 z-30 border-b border-border bg-background/95 backdrop-blur-md xl:hidden" data-mobile-toc >
33+ <div class = " fixed inset-x-0 top-16 z-30 border-b border-border bg-background/95 backdrop-blur-md xl:hidden" data-mobile-toc >
3434 <div class = " mx-auto max-w-[75rem]" style = " padding-left: clamp(1.5rem, 0.5rem + 2vw, 3rem); padding-right: clamp(1.5rem, 0.5rem + 2vw, 3rem);" >
3535 <details >
36- <summary class = " flex cursor-pointer list-none items-center gap-2 py-3 font-mono text-[10px] uppercase tracking-[0.14em] text-muted-foreground [&::-webkit-details-marker]:hidden" >
36+ <summary class = " flex cursor-pointer list-none items-center gap-2 py-3 font-mono text-[10px] leading-none uppercase tracking-[0.14em] text-muted-foreground [&::-webkit-details-marker]:hidden" >
3737 <span class = " shrink-0" >On this page</span >
3838 <span class = " truncate text-foreground/70 normal-case tracking-normal" data-toc-current ></span >
3939 <svg aria-hidden = " true" xmlns = " http://www.w3.org/2000/svg" width = " 12" height = " 12" viewBox = " 0 0 24 24" fill = " none" stroke = " currentColor" stroke-width = " 2" stroke-linecap = " round" stroke-linejoin = " round" class = " ml-auto h-3 w-3 shrink-0 transition-transform duration-200 [[open]>&]:rotate-90" ><polyline points = " 9 18 15 12 9 6" ></polyline ></svg >
@@ -195,6 +195,27 @@ const formattedDate = new Date(post.date).toLocaleDateString("en-US", {
195195</style >
196196
197197<script >
198+ // Close mobile ToC on link click or outside click
199+ const mobileToc = document.querySelector("[data-mobile-toc]");
200+ if (mobileToc) {
201+ const details = mobileToc.querySelector("details");
202+ if (details) {
203+ // Close on ToC link click
204+ mobileToc.querySelectorAll("[data-toc-link]").forEach((link) => {
205+ link.addEventListener("click", () => {
206+ details.removeAttribute("open");
207+ });
208+ });
209+
210+ // Close on outside click
211+ document.addEventListener("click", (e) => {
212+ if (details.hasAttribute("open") && !mobileToc.contains(e.target as Node)) {
213+ details.removeAttribute("open");
214+ }
215+ });
216+ }
217+ }
218+
198219 document.querySelectorAll(".blog-prose table").forEach((table) => {
199220 if (!table.parentElement?.classList.contains("table-wrapper")) {
200221 const wrapper = document.createElement("div");
0 commit comments