File tree Expand file tree Collapse file tree 3 files changed +34
-19
lines changed Expand file tree Collapse file tree 3 files changed +34
-19
lines changed Original file line number Diff line number Diff line change @@ -885,12 +885,14 @@ button:has(~ .product-selector[style*="none"]) > .product-selector-button-icon {
885
885
}
886
886
}
887
887
888
- .sidebar__link--current {
888
+ .sidebar__link--current ,
889
+ .sidebar__toggle .sidebar__link--current {
889
890
color : oklch (var (--color-brand ) / 1 );
890
891
background-color : oklch (var (--color-brand ) / 0.1 );
891
892
font-weight : 600 ;
892
- display : block; /* Make it stretch horizontally clearly */
893
- width : auto; /* reset width clearly */
893
+ display : flex;
894
+ justify-self : stretch;
895
+ width : auto;
894
896
box-sizing : border-box;
895
897
}
896
898
@@ -901,6 +903,10 @@ button:has(~ .product-selector[style*="none"]) > .product-selector-button-icon {
901
903
border-left : 1px solid var (--color-divider );
902
904
color : oklch (0 0 0 / 0.75 );
903
905
906
+ & [hidden ] {
907
+ display : none;
908
+ }
909
+
904
910
a {
905
911
color : oklch (0 0 0 / 0.75 );
906
912
text-decoration : none;
Original file line number Diff line number Diff line change @@ -5,15 +5,12 @@ document.addEventListener('click', (e) => {
5
5
const expanded = toggle . getAttribute ( 'aria-expanded' ) === 'true' ;
6
6
const panel = document . getElementById ( toggle . getAttribute ( 'aria-controls' ) ) ;
7
7
8
- // Toggle the expanded state
9
8
toggle . setAttribute ( 'aria-expanded' , String ( ! expanded ) ) ;
10
9
11
- // Toggle visibility of the content
12
10
if ( panel ) {
13
11
panel . hidden = expanded ;
14
12
}
15
13
16
- // Toggle chevron direction class
17
14
if ( chevron ) {
18
15
chevron . classList . toggle ( 'sidebar__chevron--open' , ! expanded ) ;
19
16
}
Original file line number Diff line number Diff line change 33
33
</ div >
34
34
</ li >
35
35
36
- {{ else if eq .Kind "page" }}
36
+ {{ else if eq .Kind "page" }}
37
37
< li class ="sidebar__page ">
38
- < a
39
- href ="{{ .Permalink }} "
40
- class ="sidebar__link {{ if $onPage }}sidebar__link--current{{ end }} "
41
- {{ if $onPage }}aria-current ="page "{{ end }}
42
- >
43
- {{ .Title }}
44
- </ a >
45
-
46
- {{ if $onPage }}
47
- {{ with .TableOfContents }}
48
- < div class ="sidebar__toc " id ="TableOfContents "> {{ . }}</ div >
49
- {{ end }}
38
+ {{- $pageHasTOC := (and $onPage .TableOfContents) -}}
39
+ {{- $tocID := printf "toc-%s" (urlize .Permalink) -}}
40
+ {{- if $pageHasTOC }}
41
+ < button
42
+ class ="sidebar__toggle sidebar__link sidebar__link--current "
43
+ aria-expanded ="true "
44
+ aria-controls ="{{ $tocID }} "
45
+ >
46
+ < span > {{ .Title }}</ span >
47
+ < span class ="sidebar__chevron sidebar__chevron--open ">
48
+ {{ partial "lucide" (dict "context" . "icon" "chevron-right") }}
49
+ </ span >
50
+ </ button >
51
+ < div id ="{{ $tocID }} " class ="sidebar__toc ">
52
+ {{ .TableOfContents }}
53
+ </ div >
54
+ {{ else }}
55
+ < a
56
+ href ="{{ .Permalink }} "
57
+ class ="sidebar__link {{ if $onPage }}sidebar__link--current{{ end }} "
58
+ {{ if $onPage }}aria-current ="page "{{ end }}
59
+ >
60
+ {{ .Title }}
61
+ </ a >
50
62
{{ end }}
51
63
</ li >
52
64
{{ end }}
You can’t perform that action at this time.
0 commit comments