1
0

Display TOC in sidebar

This commit is contained in:
Emil Miler 2025-05-15 21:02:19 +02:00
parent b851a127c7
commit e7d373f886
4 changed files with 61 additions and 22 deletions

View File

@ -81,6 +81,9 @@ nav {
align-self: start; align-self: start;
top: 2em; top: 2em;
margin-bottom: 4rem; margin-bottom: 4rem;
max-height: calc(100vh - 2em);
box-sizing: border-box;
overflow-y: auto;
span.title { span.title {
display: block; display: block;
@ -94,7 +97,8 @@ nav {
li a { li a {
color: #000; color: #000;
display: block; display: block;
padding: 0 .5em; line-height: 1;
padding: .25em .5em;
&:hover { &:hover {
color: #fff; color: #fff;
@ -103,6 +107,35 @@ nav {
} }
} }
} }
ul.table-of-contents li {
a {
color: #e1140a;
position: relative;
&::before, &::after {
content: "";
background-color: #bbb;
position: absolute;
left: 0;
top: 0;
}
&::before {
height: 2px;
width: .5em;
}
&::after {
width: 2px;
height: .5em;
}
&:hover { color: #fff }
&:hover::before, &:hover::after { display: none }
}
li {
padding: 0 .5em;
&>a::before, &>a::after { display: none }
}
}
} }
main { main {
@ -253,14 +286,19 @@ a {
color: inherit; color: inherit;
} }
nav ul li a { nav ul li a, nav ul.table-of-contents li a {
color: inherit; color: inherit;
&:hover { &:hover {
color: #131516; color: #131516;
background-color: #cdcdcd; background-color: #cdcdcd;
} }
} }
nav ul.table-of-contents li a {
color: #ff6e67;
&::before, &::after {
background-color: #383838;
}
}
main { main {
.info, input.search { border-color: #383838 } .info, input.search { border-color: #383838 }

View File

@ -29,6 +29,10 @@
<li><a href="{{ get_url(path=item.path, trailing_slash=true) }}">{{ item.title }}</a></li> <li><a href="{{ get_url(path=item.path, trailing_slash=true) }}">{{ item.title }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
{% if page.toc and not page.extra.notoc %}
<span class="title">Table of Contents</span>
{{ macros::toc() }}
{% endif %}
<span class="title">Categories</span> <span class="title">Categories</span>
{{ macros::list_taxonomy(kind="categories") }} {{ macros::list_taxonomy(kind="categories") }}
</nav> </nav>

View File

@ -48,8 +48,7 @@
{% endmacro %} {% endmacro %}
{% macro toc() %} {% macro toc() %}
{% if page.toc and not page.extra.notoc %} <ul class="table-of-contents">
<ul>
{% for h1 in page.toc %} {% for h1 in page.toc %}
<li> <li>
<a href="{{ h1.permalink | safe }}">{{ h1.title }}</a> <a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
@ -65,7 +64,6 @@
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %}
{% endmacro %} {% endmacro %}
{% macro list_taxonomy(kind, page=false, prepend="") %} {% macro list_taxonomy(kind, page=false, prepend="") %}

View File

@ -6,7 +6,6 @@
{% block content %} {% block content %}
<h1>{{ page.title }}</h1> <h1>{{ page.title }}</h1>
{{ macros::toc() }}
{{ page.content | safe }} {{ page.content | safe }}
{{ macros::page_info(page=page) }} {{ macros::page_info(page=page) }}
{{ macros::page_updates(page=page) }} {{ macros::page_updates(page=page) }}