Skip to content

Commit f11c750

Browse files
Color the current page in the sidebar
1 parent c7ca0ba commit f11c750

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

doc-tool/resources/css/sidebar.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
color: var(--sidebar-page);
8181
transition: color .2s ease-out;
8282
}
83-
.sidebar a:hover {
83+
.sidebar a:hover, .sidebar a.toggled {
8484
color: var(--sidebar-active) !important;
8585
}
8686

doc-tool/src/dotty/tools/dottydoc/staticsite/tags.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ object tags {
172172
suffixes.find(url.endsWith(_)).map(url.replace(_, ".html")).getOrElse(url)
173173
}
174174
private def renderTitle(t: Title, pageUrl: String): String = {
175+
val htmlPath = replaceSuffix(pageUrl, Seq("-spec.md", "-details.md", "-new.md", ".md"))
176+
val marker = if (isParent(t, htmlPath)) "class=\"toggled\"" else ""
175177
if (!t.url.isDefined && t.subsection.nonEmpty) {
176-
val htmlPath = replaceSuffix(pageUrl, Seq("-spec.md", "-details.md", ".md"))
177-
val marker = if (isParent(t, htmlPath)) "class=\"toggled\"" else ""
178178
s"""|<li class="section">
179179
| <a onclick='toggleSection(this);'>${t.title}</a>
180180
| <ul $marker>
@@ -185,7 +185,7 @@ object tags {
185185
}
186186
else if (t.url.isDefined) {
187187
val url = t.url.get
188-
s"""<li class="leaf"><a href="$baseurl/$url">${t.title}</a></li>"""
188+
s"""<li class="leaf"><a href="$baseurl/$url" $marker>${t.title}</a></li>"""
189189
}
190190
else {
191191
ctx.docbase.error(

0 commit comments

Comments
 (0)