Skip to content

Add a sticky left sidebar TOC that scrolls with the page #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion html.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,59 @@

\Configure{tableofcontents*}{chapter,section,subsection}

\Css{@media (max-width: 768px) {
.layout {
flex-direction: column;
}
aside.toc {
position: relative;
width: 100%;
max-height: none;
border-right: none;
border-bottom: 1px solid \#ccc;
}
}}

\Css{div.layout {
display: flex;
align-items: flex-start;
gap: 2rem;
max-width: 64rem;
margin: 0 auto;
}}

\Css{aside.toc {
position: sticky;
top: 2rem;
width: 16rem;
height: max-content;
max-height: 90vh;
overflow-y: auto;
padding: .2rem;
border-right: 1px solid \#ccc;
font-size: .8rem;
line-height: 1;
}}

\Css{aside span {
display: block;
}}

\Css{main {
flex: 1;
padding: 0 2rem 1rem;
min-width: 0;
}}


\Configure{tableofcontents}
{\HCode{<div class="layout"><aside class="toc">}}
{\HCode{</aside><main>}}

\Css{html {
width: 100vw;
overflow-x: hidden;
scroll-behavior: smooth;
}}

\Css{@font-face {
Expand All @@ -13,7 +63,6 @@
}}

\Css{body {
max-width: 55rem;
box-sizing: border-box;
padding: 1rem;
margin: 0 auto;
Expand All @@ -23,6 +72,15 @@
line-height: 1.5;
}}

\Css{img:first-of-type {
width: 100%;
max-width: 889px;
display: block;
margin: 0 auto 2rem;
border-radius: 5px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}}

\Css{a {
color: \#0060DF;
}}
Expand Down Expand Up @@ -88,4 +146,8 @@ font-size: 1.1em;
}

\begin{document}
\AtEndDocument{%
\HCode{</main></div>}
}

\EndPreamble
Binary file added html/Manrope_variable.ttf
Binary file not shown.
Binary file added html/assets/cover-with-names.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.