Skip to content

Commit 0f22c0d

Browse files
committed
Add a table of contents option to my markdown posts
1 parent dc9650b commit 0f22c0d

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

content/posts/2025-07-07-jujutsu.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ I was inspired to try [Jujutsu](https://github.com/martinvonz/jj) when I saw a l
1313

1414
Note: unlike some of my other posts, this one will be updated as I notice things.
1515

16+
[TOC]
17+
1618
## The Good
1719

1820
* I am really appreciating the sense of safety that comes with versioning the working copy. I've done that before, by integrating tiny commits into my editor, but that got cumbersome with always having to rebase and manage those changes.

pelicanconf.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,19 @@ def __post_init__(self):
207207
REPOSITORY_ROOT = f"file://{ Path(__file__).parent.resolve() }/{ PATH }"
208208
EDIT_CONTENT_URL = "https://github.com/offbyone/ideas/edit/main/{file_path}"
209209

210+
MARKDOWN = {
211+
"extension_configs": {
212+
"markdown.extensions.codehilite": {"css_class": "highlight"},
213+
"markdown.extensions.extra": {},
214+
"markdown.extensions.meta": {},
215+
"markdown.extensions.toc": {
216+
"permalink": True,
217+
"title": "Table of Contents",
218+
},
219+
},
220+
"output_format": "html5",
221+
}
222+
210223
if "IDEAS_EMIT_TIMING" in os.environ:
211224
import sqlite3
212225
import time

themes/offby1/scss/toc.scss

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.toc {
2+
border-radius: 0.5em;
3+
margin-bottom: 1em;
4+
background: var(--color-codebg);
5+
padding: 0.5em;
6+
margin-top: 1em;
7+
top: 30px;
8+
box-shadow: var(--color-divider) 0px 2px 8px 0px;
9+
border: 1px solid var(--color-divider);
10+
}
11+
12+
.toc ul {
13+
list-style: none;
14+
padding: 0.5rem 1rem;
15+
margin: 0;
16+
}
17+
18+
.toc ul li {
19+
padding: 0.25em;
20+
}
21+
22+
.toc ul li a {
23+
color: var(--color-primary);
24+
font-weight: 500;
25+
transition: color 0.4s;
26+
text-decoration: none;
27+
}
28+
29+
.toc ul li a:hover {
30+
color: var(--color-secondary);
31+
transition: color 0.4s;
32+
border-bottom: 1px solid var(--color-secondary);
33+
}
34+
35+
.toc ul li ul {
36+
font-size: 0.75em;
37+
font-weight: 500;
38+
margin-left: 5px;
39+
}
40+
41+
.toc ul li ul a {
42+
color: var(--color-mute);
43+
}

themes/offby1/templates/base.html.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
{% assets filters="scss",
5858
output="css/style.css",
5959
depends=["**/_*.scss"],
60-
"fuji.scss", "bigfoot-default.scss", "magnific-popup.css", "nativeads.js.scss", "adblock-detect.scss" %}
60+
"fuji.scss", "toc.scss", "bigfoot-default.scss", "magnific-popup.css", "nativeads.js.scss", "adblock-detect.scss" %}
6161
<link rel="stylesheet" href="{{ SITEURL }}/{{ ASSET_URL }}" type="text/css" />
6262
{% endassets %}
6363

0 commit comments

Comments
 (0)