|
| 1 | +--- |
| 2 | +const base = import.meta.env.BASE_URL; |
| 3 | +--- |
| 4 | + |
| 5 | +<div class="search-container"> |
| 6 | + <div id="search"></div> |
| 7 | +</div> |
| 8 | + |
| 9 | +<link href={`${base}/pagefind/pagefind-ui.css`} rel="stylesheet" /> |
| 10 | +<script is:inline define:vars={{ base }}> |
| 11 | + window.addEventListener('DOMContentLoaded', () => { |
| 12 | + const script = document.createElement('script'); |
| 13 | + script.src = `${base}/pagefind/pagefind-ui.js`; |
| 14 | + script.onload = () => { |
| 15 | + new PagefindUI({ |
| 16 | + element: '#search', |
| 17 | + showSubResults: true, |
| 18 | + showImages: false, |
| 19 | + translations: { |
| 20 | + placeholder: 'Cerca articoli e guide...', |
| 21 | + zero_results: 'Nessun risultato per "[SEARCH_TERM]"', |
| 22 | + many_results: '[COUNT] risultati per "[SEARCH_TERM]"', |
| 23 | + one_result: '1 risultato per "[SEARCH_TERM]"', |
| 24 | + clear_search: 'Cancella', |
| 25 | + load_more: 'Carica altri risultati', |
| 26 | + }, |
| 27 | + baseUrl: base |
| 28 | + }); |
| 29 | + }; |
| 30 | + document.head.appendChild(script); |
| 31 | + }); |
| 32 | +</script> |
| 33 | + |
| 34 | +<style> |
| 35 | + .search-container { |
| 36 | + max-width: 600px; |
| 37 | + margin: 0 auto 2rem; |
| 38 | + } |
| 39 | + |
| 40 | + :global(.pagefind-ui) { |
| 41 | + --pagefind-ui-scale: 1; |
| 42 | + --pagefind-ui-primary: #6366f1; |
| 43 | + --pagefind-ui-text: #f1f5f9; |
| 44 | + --pagefind-ui-background: #1e293b; |
| 45 | + --pagefind-ui-border: #334155; |
| 46 | + --pagefind-ui-tag: #334155; |
| 47 | + --pagefind-ui-border-width: 1px; |
| 48 | + --pagefind-ui-border-radius: 8px; |
| 49 | + --pagefind-ui-font: 'Segoe UI', system-ui, -apple-system, sans-serif; |
| 50 | + } |
| 51 | + |
| 52 | + :global(.pagefind-ui__search-input) { |
| 53 | + background: var(--pagefind-ui-background) !important; |
| 54 | + color: var(--pagefind-ui-text) !important; |
| 55 | + border: 1px solid var(--pagefind-ui-border) !important; |
| 56 | + padding: 0.75rem 1rem 0.75rem 2.5rem !important; |
| 57 | + font-size: 1rem !important; |
| 58 | + } |
| 59 | + |
| 60 | + :global(.pagefind-ui__search-input::placeholder) { |
| 61 | + color: #64748b !important; |
| 62 | + } |
| 63 | + |
| 64 | + :global(.pagefind-ui__search-input:focus) { |
| 65 | + border-color: var(--pagefind-ui-primary) !important; |
| 66 | + outline: none !important; |
| 67 | + box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important; |
| 68 | + } |
| 69 | + |
| 70 | + :global(.pagefind-ui__search-clear) { |
| 71 | + color: #64748b !important; |
| 72 | + background: transparent !important; |
| 73 | + } |
| 74 | + |
| 75 | + :global(.pagefind-ui__results-area) { |
| 76 | + margin-top: 1rem; |
| 77 | + } |
| 78 | + |
| 79 | + :global(.pagefind-ui__result) { |
| 80 | + background: var(--pagefind-ui-background) !important; |
| 81 | + border: 1px solid var(--pagefind-ui-border) !important; |
| 82 | + border-radius: 8px !important; |
| 83 | + padding: 1rem !important; |
| 84 | + margin-bottom: 0.75rem !important; |
| 85 | + } |
| 86 | + |
| 87 | + :global(.pagefind-ui__result:hover) { |
| 88 | + border-color: var(--pagefind-ui-primary) !important; |
| 89 | + } |
| 90 | + |
| 91 | + :global(.pagefind-ui__result-link) { |
| 92 | + color: var(--pagefind-ui-primary) !important; |
| 93 | + text-decoration: none !important; |
| 94 | + font-weight: 600 !important; |
| 95 | + } |
| 96 | + |
| 97 | + :global(.pagefind-ui__result-link:hover) { |
| 98 | + text-decoration: underline !important; |
| 99 | + } |
| 100 | + |
| 101 | + :global(.pagefind-ui__result-title) { |
| 102 | + color: var(--pagefind-ui-text) !important; |
| 103 | + } |
| 104 | + |
| 105 | + :global(.pagefind-ui__result-excerpt) { |
| 106 | + color: #94a3b8 !important; |
| 107 | + font-size: 0.9rem !important; |
| 108 | + } |
| 109 | + |
| 110 | + :global(.pagefind-ui__result-excerpt mark) { |
| 111 | + background: rgba(99, 102, 241, 0.3) !important; |
| 112 | + color: var(--pagefind-ui-text) !important; |
| 113 | + } |
| 114 | + |
| 115 | + :global(.pagefind-ui__message) { |
| 116 | + color: #94a3b8 !important; |
| 117 | + } |
| 118 | + |
| 119 | + :global(.pagefind-ui__button) { |
| 120 | + background: var(--pagefind-ui-primary) !important; |
| 121 | + color: white !important; |
| 122 | + border: none !important; |
| 123 | + border-radius: 6px !important; |
| 124 | + padding: 0.5rem 1rem !important; |
| 125 | + cursor: pointer !important; |
| 126 | + } |
| 127 | + |
| 128 | + :global(.pagefind-ui__button:hover) { |
| 129 | + opacity: 0.9 !important; |
| 130 | + } |
| 131 | +</style> |
0 commit comments