Skip to content

Commit 6b7b570

Browse files
reakaleekCopilot
andauthored
Fix table of contents progress indicator (#752)
* Fix table of contents progress indicator * Update src/Elastic.Markdown/Assets/toc-nav.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 6eff5ea commit 6b7b570

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/Elastic.Markdown/Assets/toc-nav.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ interface TocElements {
1212
const HEADING_OFFSET = 34 * 4;
1313

1414
function initializeTocElements(): TocElements {
15-
const headings = $$('h2, h3');
15+
const headings = $$('#markdown-content h2, #markdown-content h3');
1616
const tocLinks = $$('#toc-nav li>a') as HTMLAnchorElement[];
17-
const tocContainer = $('#toc-nav ul') as HTMLUListElement;
17+
const tocContainer = $('#toc-nav .toc-progress-container') as HTMLDivElement;
1818
const progressIndicator = $('.toc-progress-indicator', tocContainer) as HTMLDivElement;
19-
return { headings, tocLinks, tocContainer,progressIndicator };
19+
return { headings, tocLinks, tocContainer, progressIndicator };
2020
}
2121

2222
// Find the current TOC links based on visible headings

src/Elastic.Markdown/Slices/Layout/_TableOfContents.cshtml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@
66
{
77
<div class="mb-4">
88
<div class="font-bold mb-2">On this page</div>
9-
<ul class="block w-full relative font-body">
10-
<div class="toc-progress-indicator absolute top-0 h-0 left-2 w-[1px] bg-blue-elastic transition-all duration-200 ease-out "></div>
11-
@foreach (var item in Model.PageTocItems)
12-
{
13-
<li class="has-[:hover]:border-l-grey-80 items-center ml-2 pl-4 border-l-1 border-l-grey-20 has-[.current]:border-l-blue-elastic!">
14-
<a
15-
class="sidebar-link inline-block my-1 @(item.Level == 3 ? "ml-4" : string.Empty)"
16-
href="#@item.Slug">
17-
@item.Heading
18-
</a>
19-
</li>
20-
}
21-
</ul>
9+
<div class="relative toc-progress-container font-body">
10+
<div class="toc-progress-indicator absolute top-0 h-0 left-2 w-[1px] bg-blue-elastic transition-all duration-200 ease-out "></div>
11+
<ul class="block w-full">
12+
@foreach (var item in Model.PageTocItems)
13+
{
14+
<li class="has-[:hover]:border-l-grey-80 items-center ml-2 pl-4 border-l-1 border-l-grey-20 has-[.current]:border-l-blue-elastic!">
15+
<a
16+
class="sidebar-link inline-block my-1 @(item.Level == 3 ? "ml-4" : string.Empty)"
17+
href="#@item.Slug">
18+
@item.Heading
19+
</a>
20+
</li>
21+
}
22+
</ul>
23+
</div>
2224
</div>
2325
}
2426
<div class="edit-this-page">

0 commit comments

Comments
 (0)