Skip to content

Commit 64b4478

Browse files
committed
fix: make table of contents scrollable
1 parent eb2918b commit 64b4478

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/components/RightSidebar/RightSidebar.astro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const { editUrl, headings, langCode } = Astro.props;
3232

3333
<style>
3434
.toc {
35+
display: flex;
3536
grid-area: toc;
3637
height: fit-content;
3738
max-height: calc(100vh - var(--theme-navbar-height));
@@ -41,6 +42,11 @@ const { editUrl, headings, langCode } = Astro.props;
4142
width: fit-content;
4243
}
4344

45+
.sidebar-nav {
46+
display: flex;
47+
flex-direction: column;
48+
}
49+
4450
@media (max-width: 1080px) {
4551
aside.toc {
4652
display: none;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
h2.heading {
22
font-size: 1.125em;
33
}
4+
5+
ul.table-of-contents {
6+
overflow: auto;
7+
position: relative;
8+
}

src/components/RightSidebar/TableOfContents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { FunctionalComponent } from 'preact';
33
import type { MouseEvent } from 'react';
44
import { unescape } from 'html-escaper';
55
import {
6-
useEffect, useRef, useState
6+
useEffect, useRef, useState
77
} from 'preact/hooks';
88

99
import './TableOfContents.css';
@@ -92,7 +92,7 @@ const TableOfContents: FunctionalComponent<Props> = ({
9292
<h2 id={onThisPageID} className="heading">
9393
{onThisPage}
9494
</h2>
95-
<ul ref={toc}>
95+
<ul className="table-of-contents" ref={toc}>
9696
{headings
9797
.filter(({ depth }) => depth > 1 && depth < 4)
9898
.map((heading) => {

0 commit comments

Comments
 (0)