search: refactor page entries in toc

Wraps the entry title in a span element so that we can have a single
querySelector to get the textContent of the title of a top-level toc
item of a page:

document.querySelector("#sectiontree li:has([aria-current]) :is(a, button) span")

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2023-11-22 20:43:36 +01:00
parent fd264a9df3
commit 3ac25b7a2c
1 changed files with 4 additions and 4 deletions

View File

@ -53,10 +53,10 @@
{{ $isCurrent := eq (urls.Parse $ctx.Permalink).Path .entry.path }}
<li class="pl-4 sidebar-hover rounded
{{ if $isCurrent }} bg-gray-light-200 dark:bg-gray-dark-200{{ end }}">
<span class="flex items-center">
<a {{ if $isCurrent }}aria-current="page" {{ end }} class="py-2 w-full truncate"
href="{{ .entry.path }}" title="{{ markdownify .entry.title }}">{{ markdownify .entry.title }}</a>
</span>
<a {{ if $isCurrent }}aria-current="page" {{ end }} class="py-2 w-full truncate block"
href="{{ .entry.path }}" title="{{ markdownify .entry.title }}"
><span>{{ markdownify .entry.title }}</span>
</a>
</li>
{{ end }}
{{ end }}