Add site search (Pagefind)
Client-side index generated after the Hugo build; search box in the header, results page with a section filter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YDRjtmAiNpo5mK5N3d7QwZ
This commit is contained in:
+8
-1
@@ -18,8 +18,15 @@
|
||||
<a href="{{ .URL }}"{{ if or ($current.IsMenuCurrent .Menu .) ($current.HasMenuCurrent .Menu .) (eq $current.Section .Page.Section) }} class="active"{{ end }}>{{ .Name }}</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
<form class="search" role="search" action="{{ "search/" | relURL }}" method="get">
|
||||
<input type="search" name="q" placeholder="Search…" aria-label="Search the site">
|
||||
</form>
|
||||
</header>
|
||||
<main>
|
||||
{{/* search index: content pages only (not lists), filterable by section; see layouts/search.html */}}
|
||||
{{ $indexed := and .IsPage (ne .Layout "search") (ne .Params.tab "comments") }}
|
||||
{{ $section := "" }}{{ with .FirstSection }}{{ if not .IsHome }}{{ $section = .Title }}{{ end }}{{ end }}
|
||||
{{ if eq .Section "machine-tabs" }}{{ $section = "Museum" }}{{ end }}
|
||||
<main{{ if $indexed }} data-pagefind-body{{ with $section }} data-pagefind-filter="Section:{{ . }}"{{ end }}{{ end }}>
|
||||
{{ block "main" . }}{{ end }}
|
||||
</main>
|
||||
<footer class="site-footer">
|
||||
|
||||
Reference in New Issue
Block a user