Skip to content

Commit db1827f

Browse files
authored
Merge pull request #15 from sekthor/feat/toc
feat(#7): add table of contents
2 parents 169e8fc + b7e78bd commit db1827f

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

assets/css/main.css

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,32 @@ header a {
3333
text-decoration: none;
3434
}
3535

36+
.toc {
37+
position: fixed;
38+
right:2em;
39+
top: 7em;
40+
padding: 1em;
41+
border: 1px solid #ddd;
42+
background-color: #fff;
43+
font-size: smaller;
44+
width: 135px;
45+
}
46+
47+
.toc ul {
48+
list-style: none;
49+
padding-left: 0;
50+
margin: 0;
51+
white-space: nowrap;
52+
overflow: hidden;
53+
text-overflow: ellipsis;
54+
}
55+
56+
.toc ul ul {
57+
padding-left: 1em;
58+
}
59+
3660
main {
37-
max-width: 768px;
61+
max-width: 765px;
3862
margin: 3em auto;
3963
padding: 1em;
4064
}
@@ -54,6 +78,8 @@ h1 {
5478
h2, h3, h4 {
5579
border-bottom: 1px solid darkorange;
5680
font-weight: normal;
81+
padding-top: 48px;
82+
margin-top: -24px;
5783
}
5884

5985
time {
@@ -150,4 +176,21 @@ blockquote {
150176

151177
.profile:hover {
152178
box-shadow: 2px 2px 10px #ddd;
179+
}
180+
181+
@media (max-width: 1100px) {
182+
main {
183+
margin-left: 0;
184+
}
185+
.toc {
186+
right: 0;
187+
}
188+
}
189+
@media (max-width: 950px) {
190+
main {
191+
max-width: 100%;
192+
}
193+
.toc {
194+
display: none;
195+
}
153196
}

layouts/_default/baseof.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
<header>
88
{{ partial "header.html" . }}
99
</header>
10+
{{ if .IsPage }}
11+
{{ with .TableOfContents }}
12+
{{ if ne . "<nav id=\"TableOfContents\"></nav>" }}
13+
<div class="toc">
14+
<strong>Table of Contents</strong>
15+
{{ . }}
16+
</div>
17+
{{ end }}
18+
{{ end }}
19+
{{ end }}
1020
<main>
1121
{{ block "main" . }}{{ end }}
1222
</main>

0 commit comments

Comments
 (0)