Skip to content

Commit b7250b9

Browse files
committed
feat: move backlinks and toc to a single sidebar
1 parent 9029411 commit b7250b9

4 files changed

Lines changed: 46 additions & 47 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
!.gitignore
33

44
courses/
5+
public/
56

67
*.org
78
*.aux

static/graph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ document.addEventListener("DOMContentLoaded", () => {
66
const title = document.getElementsByClassName("title")[0].textContent;
77
const backlinks = document.getElementsByClassName("backlinks");
88

9-
const width = 300;
9+
const width = 200;
1010
const height = 200;
1111

1212
const nodes = [...backlinks].map(link => ({ id: link.textContent }));

static/style.css

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ button {
6565
margin-bottom: 8px;
6666
}
6767

68+
.no_margin_below {
69+
margin-bottom: 0px;
70+
}
71+
6872
.margin_bottom-large {
6973
margin-bottom: 40px;
7074
}
@@ -357,10 +361,10 @@ pre code {
357361

358362
.grid {
359363
display: grid;
360-
grid-template-areas: "sidebar content";
361-
grid-template-columns: 320px minmax(500px, 750px);
364+
grid-template-areas: "space content sidebar";
365+
grid-template-columns: minmax(90px, 320px) minmax(500px, 750px) 320px;
362366

363-
@media screen and (max-width: 1100px) {
367+
@media screen and (max-width: 900px) {
364368
grid-template-areas: "content";
365369
grid-template-columns: 100%;
366370
}
@@ -370,13 +374,13 @@ pre code {
370374
grid-area: content;
371375
max-width: 750px;
372376

373-
@media screen and (max-width: 800px) {
377+
@media screen and (max-width: 900px) {
374378
max-width: 100%;
375-
margin: 0 1vw;
379+
margin: 0 4vw;
376380
}
377381
}
378382

379-
.grid-toc {
383+
.grid-sidebar {
380384
grid-area: sidebar;
381385
position: sticky;
382386
top: 1rem;
@@ -390,7 +394,7 @@ pre code {
390394
font-size: 0.8rem;
391395
}
392396

393-
@media screen and (max-width: 1100px) {
397+
@media screen and (max-width: 900px) {
394398
display: none;
395399
}
396400
}

templates/page.html

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,47 @@
33
{% block content %}
44

55
<main class="grid">
6-
{% if page.toc %}
7-
<div class="grid-toc">
8-
<h3 class="margin_below">Table of Contents</h3>
9-
<div class="row row-start row-stretch row-gap">
10-
<div class="row">
11-
<div class="medium_small_spacer"></div>
12-
<div>&nbsp;</div>
13-
<div class="small_spacer"></div>
14-
</div>
15-
<div>
16-
<!-- <div class="row margin_below"> -->
17-
<!-- <div class="square"></div> <div class="hline halfwidth"></div> <div class="square"></div> -->
18-
<!-- </div> -->
6+
<div class="grid-sidebar">
7+
{% if page.backlinks %}
8+
<h5 class="margin_below">Backlinks Graph</h5>
9+
<svg id=backlink-graph width="200" height="200" xmlns="http://www.w3.org/2000/svg">
10+
</svg>
11+
<h5 class="no_margin_below">Backlinks </h5>
1912
<ul class="toc-ul">
20-
{% for h1 in page.toc %}
21-
<li>
22-
<a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
23-
{% if h1.children %}
24-
<ul>
25-
{% for h2 in h1.children %}
13+
{% for backlink in page.backlinks %}
14+
<li><a class="backlinks" href="{{ backlink.permalink }}">{{ backlink.title }}</a></li>
15+
{% endfor %}
16+
</ul>
17+
{% endif %}
18+
19+
{% if page.toc %}
20+
<h5 class="no_margin_below">Table of Contents</h5>
21+
<div class="margin row row-start row-stretch row-gap">
22+
<div class="row"> <div class="medium_small_spacer"></div> <div>&nbsp;</div> <div class="small_spacer"></div> </div>
23+
<div>
24+
<ul class="toc-ul">
25+
{% for h1 in page.toc %}
2626
<li>
27-
<a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
27+
<a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
28+
{% if h1.children %}
29+
<ul>
30+
{% for h2 in h1.children %}
31+
<li>
32+
<a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
33+
</li>
34+
{% endfor %}
35+
</ul>
36+
{% endif %}
2837
</li>
2938
{% endfor %}
3039
</ul>
31-
{% endif %}
32-
</li>
33-
{% endfor %}
34-
</ul>
35-
</div>
3640
</div>
41+
</div>
42+
{% endif %}
43+
</div>
3744
<!-- <div class="row margin_below"> -->
3845
<!-- <div class="square"></div> <div class="hline halfwidth"></div> <div class="square"></div> -->
3946
<!-- </div> -->
40-
</div>
41-
{% endif %}
4247
<div class="grid-content">
4348
<h1 class="title">{{ page.title }}</h1>
4449

@@ -50,7 +55,7 @@ <h1 class="title">{{ page.title }}</h1>
5055
</div>
5156
{% endif %}
5257

53-
{% if page.updated %}
58+
{% if page.updated %}
5459
<div class="row">
5560
<svg xmlns="http://www.w3.org/2000/svg" class="icon" fill="currentColor" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><path d="M92.69,216H48a8,8,0,0,1-8-8V163.31a8,8,0,0,1,2.34-5.65L165.66,34.34a8,8,0,0,1,11.31,0L221.66,79a8,8,0,0,1,0,11.31L98.34,213.66A8,8,0,0,1,92.69,216Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="136" y1="64" x2="192" y2="120" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="164" y1="92" x2="68" y2="188" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="95.49" y1="215.49" x2="40.51" y2="160.51" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>
5661
<p>&nbsp Edited: {{ page.updated }}</p>
@@ -71,17 +76,6 @@ <h1 class="title">{{ page.title }}</h1>
7176

7277
{{ page.content | safe }}
7378

74-
{% if page.backlinks %}
75-
<h2>Backlinks</h2>
76-
<ul>
77-
{% for backlink in page.backlinks %}
78-
<li><a class="backlinks" href="{{ backlink.permalink }}">{{ backlink.title }}</a></li>
79-
{% endfor %}
80-
</ul>
81-
{% endif %}
82-
83-
<svg id=backlink-graph width="300" height="200" xmlns="http://www.w3.org/2000/svg">
84-
</svg>
8579
</div>
8680
</main>
8781

0 commit comments

Comments
 (0)