| 1 | {{- define "main" -}} |
| 2 | <header class="page-header"> |
| 3 | {{- partial "breadcrumbs.html" . }} |
| 4 | <h1>{{ .Title }}</h1> |
| 5 | {{- with (.Description | default .Params.summary) }} |
| 6 | <div class="post-description">{{ . }}</div> |
| 7 | {{- end }} |
| 8 | </header> |
| 9 | |
| 10 | {{- if .Content }} |
| 11 | <div class="post-content md-content"> |
| 12 | {{ .Content }} |
| 13 | </div> |
| 14 | {{- end }} |
| 15 | |
| 16 | <section class="search-shell" aria-labelledby="search-interface-title"> |
| 17 | <div class="search-intro-card"> |
| 18 | <span class="section-topline">Static search</span> |
| 19 | <h2 id="search-interface-title">Find trends by keyword or filter</h2> |
| 20 | <p>Search every published report, then narrow the results by category, tag, year, or featured repository.</p> |
| 21 | <div class="search-shortcuts" id="search-shortcuts" aria-label="Search keyboard shortcuts"> |
| 22 | <span class="search-shortcuts-title">Keyboard</span> |
| 23 | <span class="search-shortcut"><kbd>/</kbd><span>Focus search</span></span> |
| 24 | <span class="search-shortcut"><kbd>Tab</kbd><span>Move through filters and results</span></span> |
| 25 | <span class="search-shortcut"><kbd>Enter</kbd><span>Open a result</span></span> |
| 26 | </div> |
| 27 | <p id="search-help" class="visually-hidden">Search every Claracle report by keyword or filter. Use slash to focus the search field, Tab to move through filters and results, and Enter to open a result.</p> |
| 28 | </div> |
| 29 | <div id="search" class="search-panel" role="search" aria-labelledby="search-interface-title" aria-describedby="search-help search-shortcuts"></div> |
| 30 | </section> |
| 31 | |
| 32 | <script> |
| 33 | window.addEventListener("DOMContentLoaded", function () { |
| 34 | const searchElement = document.getElementById("search"); |
| 35 | if (!searchElement || !window.PagefindUI) return; |
| 36 | |
| 37 | const applyA11y = function () { |
| 38 | const input = searchElement.querySelector(".pagefind-ui__search-input"); |
| 39 | if (input) { |
| 40 | input.setAttribute("aria-label", "Search Claracle reports"); |
| 41 | input.setAttribute("aria-describedby", "search-help search-shortcuts"); |
| 42 | } |
| 43 | |
| 44 | const results = searchElement.querySelector(".pagefind-ui__results"); |
| 45 | if (results) { |
| 46 | results.setAttribute("aria-live", "polite"); |
| 47 | results.setAttribute("aria-label", "Search results"); |
| 48 | } |
| 49 | |
| 50 | const clearButton = searchElement.querySelector(".pagefind-ui__search-clear"); |
| 51 | if (clearButton && !clearButton.getAttribute("aria-label")) { |
| 52 | clearButton.setAttribute("aria-label", "Clear search query"); |
| 53 | } |
| 54 | |
| 55 | searchElement.querySelectorAll("button").forEach(function (button) { |
| 56 | if (!button.getAttribute("aria-label")) { |
| 57 | const label = button.textContent.trim(); |
| 58 | if (label) { |
| 59 | button.setAttribute("aria-label", label); |
| 60 | } |
| 61 | } |
| 62 | }); |
| 63 | }; |
| 64 | |
| 65 | const observer = new MutationObserver(applyA11y); |
| 66 | observer.observe(searchElement, { childList: true, subtree: true }); |
| 67 | |
| 68 | new PagefindUI({ |
| 69 | element: "#search", |
| 70 | bundlePath: "{{ `pagefind/` | absURL }}", |
| 71 | showSubResults: true, |
| 72 | showImages: false, |
| 73 | excerptLength: 24, |
| 74 | focusOnSlash: true, |
| 75 | sort: { date: "desc" }, |
| 76 | openFilters: ["Categories", "Tags", "Repository", "Year"], |
| 77 | translations: { |
| 78 | placeholder: "Search reports, tags, categories, or repos" |
| 79 | } |
| 80 | }); |
| 81 | |
| 82 | requestAnimationFrame(applyA11y); |
| 83 | }); |
| 84 | </script> |
| 85 | {{- end -}} |