Skip to content

Commit 6f99f9e

Browse files
committed
use scrollspy on docs pages
1 parent d9da43f commit 6f99f9e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

site/assets/scss/_toc.scss

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,26 @@
1313
nav {
1414
@include font-size(.875rem);
1515

16-
ul {
17-
padding-left: 0;
18-
list-style: none;
19-
20-
ul {
16+
nav {
17+
nav {
2118
padding-left: 1rem;
2219
margin-top: .25rem;
2320
}
2421
}
2522

2623
li {
2724
margin-bottom: .25rem;
25+
26+
> .nav-link.active {
27+
background-color: $bd-purple-light;
28+
}
2829
}
2930

3031
a {
3132
color: inherit;
3233

33-
&:not(:hover) {
34-
text-decoration: none;
34+
&:hover:not(.active) {
35+
text-decoration: underline;
3536
}
3637

3738
code {

site/layouts/_default/docs.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{ define "body_override" }}<body data-bs-spy="scroll" data-bs-offset="30" tabindex="0" data-bs-target="#TableOfContents">{{ end }}
12
{{ define "main" }}
23
{{ partial "docs-subnav" . }}
34

@@ -19,7 +20,7 @@ <h1 class="bd-title" id="content">{{ .Title | markdownify }}</h1>
1920
{{ if (eq .Page.Params.toc true) }}
2021
<div class="bd-toc mt-4 mb-5 my-md-0 ps-xl-3 mb-lg-5 text-muted">
2122
<strong class="d-block h6 my-2 pb-2 border-bottom">On this page</strong>
22-
{{ .TableOfContents }}
23+
{{ .Page.TableOfContents | replaceRE "(<li>)" "<li class=\"nav-item\">" | replaceRE "(</ul>)" "</nav>" | replaceRE "(<ul>)" "<nav class=\"nav nav-pills flex-column\">" | replaceRE "(?s:href)" "class=\"nav-link py-0 px-1\" href" | safeHTML }}
2324
</div>
2425
{{ end }}
2526

0 commit comments

Comments
 (0)