Skip to content

Commit 3aa6ccd

Browse files
committed
ui: implement TOC fallback for small screens and robust hiding logic
1 parent e7e5757 commit 3aa6ccd

5 files changed

Lines changed: 68 additions & 1 deletion

File tree

assets/style.css

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,58 @@ nav a:hover {
502502
display: none;
503503
}
504504

505+
.toc-sidebar:not(:has(li)),
506+
.toc-fallback:not(:has(li)) {
507+
display: none !important;
508+
}
509+
510+
.toc-fallback {
511+
margin: 2rem 0;
512+
padding: 1.25rem;
513+
background: var(--bg-secondary);
514+
border: 1px solid var(--border-subtle);
515+
border-radius: 8px;
516+
}
517+
518+
.toc-fallback h3 {
519+
margin-top: 0;
520+
margin-bottom: 1rem;
521+
font-size: 1rem;
522+
color: var(--text-tertiary);
523+
text-transform: uppercase;
524+
letter-spacing: 0.05em;
525+
font-weight: 600;
526+
}
527+
528+
.toc-fallback ul {
529+
list-style: none;
530+
padding: 0;
531+
margin: 0;
532+
}
533+
534+
.toc-fallback li {
535+
margin: 0.4rem 0;
536+
}
537+
538+
.toc-fallback a {
539+
color: var(--text-secondary);
540+
text-decoration: none;
541+
font-size: 0.9rem;
542+
}
543+
544+
.toc-fallback a:hover {
545+
color: var(--brand-primary);
546+
text-decoration: underline;
547+
}
548+
549+
.toc-fallback ul ul {
550+
padding-left: 1.5rem;
551+
}
552+
505553
@media screen and (min-width: 1024px) {
554+
.toc-fallback {
555+
display: none;
556+
}
506557
.container {
507558
max-width: 1100px;
508559
}

layouts/learn.shtml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
</head>
44
<body id="body">
55
<div class="content-wrapper">
6-
<div class="toc-sidebar" :if="$page.custom.getOr('toc', true).and($page.isSection().not()).and($page.toc().len().gt(11))">
6+
<div class="toc-sidebar" :if="$page.custom.getOr('toc', true).and($page.isSection().not())">
77
<div class="toc-sticky">
88
<div :html="$page.toc()"></div>
99
</div>
1010
</div>
1111
<div class="main-content">
1212
<h1 :text="$page.title"></h1>
13+
<div class="toc-fallback" :if="$page.isSection().not().and($page.custom.getOr('toc', true))">
14+
<h3>Table Of Content</h3>
15+
<div :html="$page.toc()"></div>
16+
</div>
1317
<div :html="$page.content()"></div>
1418
<div id="prev-next" :if="$page.isSection().not()">
1519
<div :if="$page.prevPage?()">

layouts/monthly.shtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232

3333
<!-- Article Page: Content + Prev/Next -->
3434
<div :if="$page.isSection().not()">
35+
<div class="toc-fallback" :if="$page.custom.getOr('toc', true)">
36+
<h3>Table Of Content</h3>
37+
<div :html="$page.toc()"></div>
38+
</div>
3539
<div :html="$page.content()" class="monthly-content"></div>
3640
<div id="prev-next">
3741
<div :if="$page.prevPage?()">

layouts/post.shtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
<span :text="$page.date.format('January 02, 2006')"></span>
6767
</p>
6868
</div>
69+
<div class="toc-fallback" :if="$page.custom.getOr('toc', true)">
70+
<h3>Table Of Content</h3>
71+
<div :html="$page.toc()"></div>
72+
</div>
6973
<div :html="$page.content()"></div>
7074
<div id="prev-next">
7175
<div :if="$page.prevPage?()">

layouts/templates/content.shtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
<p :text="$page.date.format('2006-01-03')"></p>
1616
<p :text="$page.author" id="author"></p>
1717
</div>
18+
<div class="toc-fallback" :if="$page.custom.getOr('toc', true).and($page.isSection().not())">
19+
<h3>Table Of Content</h3>
20+
<div :html="$page.toc()"></div>
21+
</div>
1822
<ul class="article-list" :loop="$page.subpages()">
1923
<li>
2024
<a href="$loop.it.link()" class="article-item">

0 commit comments

Comments
 (0)