Skip to content

Commit 88d2768

Browse files
author
OpenClaw Sync
committed
Fix TOC heading extraction and spacing
1 parent 67f2ef6 commit 88d2768

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

_layouts/post.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ <h1>{{ page.title }}</h1>
2323
<nav class="post-toc" aria-label="Table of contents">
2424
<p class="toc-label">Contents</p>
2525
<ul>
26-
{% assign headings = content | split: '<h2' %}
26+
{% assign headings = content | split: '<h2 id="' %}
2727
{% for heading in headings %}
28-
{% if heading contains 'id="' %}
29-
{% assign id = heading | split: 'id="' | last | split: '"' | first %}
30-
{% assign text = heading | split: '>' | slice: 1 | join: '>' | split: '</h2>' | first %}
28+
{% unless forloop.first %}
29+
{% assign id = heading | split: '"' | first %}
30+
{% assign text = heading | split: '">' | last | split: '</h2>' | first %}
3131
<li><a href="#{{ id }}">{{ text | strip_html }}</a></li>
32-
{% endif %}
32+
{% endunless %}
3333
{% endfor %}
3434
</ul>
3535
</nav>

assets/css/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ main {
451451
/* Table of contents */
452452
.post-toc {
453453
max-width: 760px;
454-
margin: 0 auto 1.5rem;
454+
margin: 1rem auto 1.5rem;
455455
padding: 1rem 1.25rem;
456456
border: 1px solid var(--line);
457457
border-radius: var(--radius);

0 commit comments

Comments
 (0)