Skip to content

Commit 6f7329b

Browse files
authored
Merge pull request #26 from Slavetomints/feat/table-of-contents implements #21
Add Table of Contents
2 parents 7bb11f3 + 179b760 commit 6f7329b

5 files changed

Lines changed: 64 additions & 10 deletions

File tree

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ source 'https://rubygems.org'
44

55
# Specify your gem's dependencies in jekyll-theme-nyx.gemspec
66
gemspec
7+
8+
gem "jekyll-toc", "~> 0.19.0"

Gemfile.lock

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@ GEM
1818
eventmachine (>= 0.12.9)
1919
http_parser.rb (~> 0)
2020
eventmachine (1.2.7)
21-
ffi (1.17.3)
2221
ffi (1.17.3-x86_64-linux-gnu)
2322
forwardable-extended (2.6.0)
24-
google-protobuf (4.33.2)
25-
bigdecimal
26-
rake (>= 13)
2723
google-protobuf (4.33.2-x86_64-linux-gnu)
2824
bigdecimal
2925
rake (>= 13)
@@ -51,6 +47,9 @@ GEM
5147
webrick (~> 1.7)
5248
jekyll-sass-converter (3.1.0)
5349
sass-embedded (~> 1.75)
50+
jekyll-toc (0.19.0)
51+
jekyll (>= 3.9)
52+
nokogiri (~> 1.12)
5453
jekyll-watch (2.2.1)
5554
listen (~> 3.0)
5655
json (2.18.0)
@@ -63,19 +62,19 @@ GEM
6362
rb-fsevent (~> 0.10, >= 0.10.3)
6463
rb-inotify (~> 0.9, >= 0.9.10)
6564
mercenary (0.4.0)
65+
nokogiri (1.19.0-x86_64-linux-gnu)
66+
racc (~> 1.4)
6667
pathutil (0.16.2)
6768
forwardable-extended (~> 2.6)
6869
public_suffix (7.0.0)
70+
racc (1.8.1)
6971
rake (13.3.0)
7072
rb-fsevent (0.11.2)
7173
rb-inotify (0.11.1)
7274
ffi (~> 1.0)
7375
rexml (3.4.4)
7476
rouge (4.7.0)
7577
safe_yaml (1.0.5)
76-
sass-embedded (1.97.1)
77-
google-protobuf (~> 4.31)
78-
rake (>= 13)
7978
sass-embedded (1.97.1-x86_64-linux-gnu)
8079
google-protobuf (~> 4.31)
8180
terminal-table (3.0.2)
@@ -84,11 +83,11 @@ GEM
8483
webrick (1.9.2)
8584

8685
PLATFORMS
87-
ruby
8886
x86_64-linux
8987

9088
DEPENDENCIES
9189
jekyll-theme-nyx!
90+
jekyll-toc (~> 0.19.0)
9291

9392
BUNDLED WITH
9493
2.6.7

_config.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ collections:
2525
permalink: /:name/
2626
sort_by: order
2727

28+
plugins:
29+
- jekyll-toc
30+
2831
defaults:
2932
- scope:
3033
path: ""
3134
type: posts
3235
values:
3336
layout: post
34-
permalink: /posts/:title/
37+
permalink: /posts/:title/
38+
toc: true

_layouts/post.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,13 @@ layout: default
55
<h1>{{ page.title }}</h1>
66
<p>{{ page.date | date: "%B %d, %Y" }} – Written by {{ page.author }}</p>
77
</header>
8-
{{ content }}
98

9+
<div id="post-container">
10+
<article>
11+
{{ content }}
12+
</article>
13+
<aside>
14+
<h2>Table of Contents</h2>
15+
{{ content | toc_only }}
16+
</aside>
17+
</div>

_sass/nyx/_layout.scss

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ footer {
55
padding: $space-2 $space-3;
66
}
77

8+
aside {
9+
width: auto;
10+
flex-shrink: 0;
11+
12+
position: sticky;
13+
top: $space-4;
14+
15+
max-height: calc(100vh - $space-4 * 2);
16+
overflow-y: auto;
17+
18+
@media (max-width: 600px) {
19+
display: none;
20+
}
21+
}
22+
23+
824
main {
925
display: flex;
1026
flex-direction: column;
@@ -16,6 +32,17 @@ main {
1632
}
1733
}
1834

35+
/* POST CONTAINER */
36+
#post-container {
37+
display: flex;
38+
gap: $space-4;
39+
@media (max-width: 600px) {
40+
display: block;;
41+
}
42+
}
43+
44+
45+
1946
/* STYLING FOR /POSTS/ */
2047

2148
.post-list {
@@ -124,3 +151,17 @@ main {
124151
padding: 0.15rem 0.5rem;
125152
border-radius: 999px;
126153
}
154+
155+
156+
#toc li {
157+
list-style: none;
158+
}
159+
160+
#toc a {
161+
color: $muted
162+
}
163+
164+
#toc a:hover{
165+
text-decoration: none;
166+
color: $fg;
167+
}

0 commit comments

Comments
 (0)