Skip to content

Commit bae2206

Browse files
committed
site: show breadcrumbs in search results
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent 70f64d0 commit bae2206

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

layouts/partials/pagefind-meta.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{- $description := partial "utils/description.html" . -}}
33
{{- $keywords := partialCached "utils/keywords.html" . . -}}
44
{{- $breadcrumbs := slice -}}
5-
{{- range .Ancestors.Reverse -}}
5+
{{- range after 1 .Ancestors.Reverse -}}
66
{{- $breadcrumbs = $breadcrumbs | append .LinkTitle -}}
77
{{- end -}}
88
{{- with $description }}<meta data-pagefind-meta="description:{{ . }}">{{ end }}

layouts/partials/search-bar.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
<pagefind-results>
4747
<script type="text/pagefind-template">
4848
<li class="py-3 border-b border-gray-200 dark:border-gray-700 last:border-b-0">
49+
{{ print "{{#if meta.breadcrumbs}}" }}
50+
<p class="text-xs text-gray-500 dark:text-gray-400 mb-1">{{ print "{{ meta.breadcrumbs }}" }}</p>
51+
{{ print "{{/if}}" }}
4952
<p class="font-medium">
5053
<a class="text-blue-600 dark:text-blue-400 hover:underline" href="{{ print "{{ meta.url | default(url) | safeUrl }}" }}">
5154
{{ print "{{ meta.title }}" }}

0 commit comments

Comments
 (0)