Introduce Article Info Sidebar and Improve Markdown Page Layout: TOC, Mermaid
Summary
Refactored the
OneArticleOnPage.astro layout to properly handle table of contents, mermaid charts, and a new document info sidebar.Why Care
These improvements significantly enhance usability and structure of long markdown documents, providing more navigability (TOC), visual clarity (chart expansion), and metadata context (info sidebar).
Implementation
Changes Made
- Added a sticky
info-sidebaron the left for showing document metadata (path,id,author, etc.) - Refactored
TableOfContents.astroto apply styles correctly when called fromAstroMarkdown - Resolved issues where
.toc-sidebarstyles were not being applied when injected dynamically - Prevented chart overflow from breaking layout by constraining
.mermaid-breakoutwidth to container - Completely rewrote fullscreen logic for Mermaid charts using
toggleMermaidExpand()with lightbox behavior - Ensured responsive resizing and modal structure for fullscreen Mermaid rendering
- Added global styles for
mermaid-fullscreen-modal - Preserved all sidebar widths across breakpoints
- Ensured fallback TOC title rendering inherits proper styles
Technical Details
OneArticleOnPage.astro:- Introduced
.info-sidebarand styled it consistently with.toc-sidebar - Removed duplicate
.toc-sidebarmarkup; rendering now fully handled viaAstroMarkdownandTableOfContents.astro - Ensured
.content-wrapperuses flexbox andalign-items: flex-startto keep sidebar positioning stable
TableOfContents.astro:- Renders nested ToC nodes recursively with unified styles
- Removed redundant hover and text color rules
- Applied
.toc-scroll-areawrapper only when content exists, with scroll disabled
- Mermaid chart styling:
.mermaid-chart-shellnow respects container width and avoids overflow.mermaid-fullscreen-modalgives fullscreen chart display with high z-index and escape key support- Added expand/collapse toggle using inline SVG
Integration Points
- AstroMarkdown.astro: calls
<TableOfContents />based onnode.type === "tableOfContents" - Relies on
remark-tocinjecting a validtableOfContentsnode withdata.mapas list
Documentation
- No external docs modified yet, but README could benefit from a "Markdown Layout Structure" section
- All changes tested in
/pages/vocabulary/[slug].astrovia live Markdown rendering - Will need follow-up to generalize info-sidebar metadata fields from frontmatter