source: Klonkt/src/views/pages/search.ejs@ 7bc636b

main
Last change on this file since 7bc636b was 7bc636b, checked in by Robin <robin@…>, 4 months ago

Initial commit — PrutFolio v1 source (pulled from Hetzner /srv/prutfolio)

  • Property mode set to 100644
File size: 3.2 KB
Line 
1<div class="container search-page">
2 <h1>Search</h1>
3
4 <form method="get" action="/search" class="search-page-form">
5 <input
6 type="search"
7 name="q"
8 value="<%= query %>"
9 placeholder="Search posts…"
10 autocomplete="off"
11 autofocus
12 aria-label="Search query">
13 <button type="submit" class="btn btn-primary">Search</button>
14 </form>
15
16 <% if (queryError) { %>
17 <p class="search-error">Couldn't run that query. Try a simpler term.</p>
18 <% } %>
19
20 <% if (query && !queryError) { %>
21 <p class="search-meta">
22 <%= total %> result<%= total === 1 ? '' : 's' %> for &ldquo;<%= query %>&rdquo;
23 </p>
24 <% } %>
25
26 <% if (results && results.length) { %>
27 <ol class="search-results">
28 <% results.forEach(function(r) { %>
29 <li class="search-result">
30 <h2 class="search-result-title">
31 <a href="/<%= r.slug %>"
32 hx-get="/<%= r.slug %>?partial=1"
33 hx-target="#pcms-main"
34 hx-swap="innerHTML"
35 hx-push-url="/<%= r.slug %>"
36 hx-indicator="#pcms-loading">
37 <%= r.title || '(untitled)' %>
38 </a>
39 </h2>
40 <p class="search-result-meta">
41 <%= r.author_username %>
42 <% if (r.published_at) { %> &middot; <%= formatDate(r.published_at) %><% } %>
43 </p>
44 <p class="search-result-snippet"><%- r.snippet %></p>
45 </li>
46 <% }); %>
47 </ol>
48 <% } else if (query && !queryError) { %>
49 <p class="search-empty">No posts found.</p>
50 <% } %>
51</div>
52
53<style>
54.search-page { max-width: 720px; margin: 3rem auto; padding: 0 1rem; }
55.search-page h1 { font-family: var(--font-display, serif); font-size: 2rem; margin: 0 0 1.5rem; }
56
57.search-page-form {
58 display: flex;
59 gap: 0.5rem;
60 margin-bottom: 1.5rem;
61}
62.search-page-form input {
63 flex: 1;
64 padding: 0.6rem 0.9rem;
65 border: 1px solid var(--rule);
66 border-radius: 5px;
67 background: var(--paper-2);
68 color: var(--ink);
69 font-size: 1rem;
70}
71.search-page-form input:focus {
72 outline: none;
73 border-color: var(--accent);
74}
75
76.search-meta {
77 color: var(--ink-muted, var(--ink-soft));
78 font-size: 0.9rem;
79 margin: 0 0 1rem;
80}
81.search-error {
82 background: rgba(200, 60, 60, 0.15);
83 color: #c33;
84 padding: 0.75rem 1rem;
85 border-radius: 6px;
86 border: 1px solid rgba(200, 60, 60, 0.3);
87}
88.search-empty {
89 color: var(--ink-muted, var(--ink-soft));
90 text-align: center;
91 margin: 3rem 0;
92}
93
94.search-results {
95 list-style: none;
96 margin: 0;
97 padding: 0;
98 counter-reset: search-result;
99}
100.search-result {
101 padding: 1rem 0;
102 border-bottom: 1px solid var(--rule);
103}
104.search-result:last-child { border-bottom: 0; }
105
106.search-result-title {
107 font-family: var(--font-display, serif);
108 font-size: 1.25rem;
109 margin: 0 0 0.25rem;
110}
111.search-result-title a {
112 color: var(--ink);
113 text-decoration: none;
114}
115.search-result-title a:hover { color: var(--accent); }
116
117.search-result-meta {
118 margin: 0 0 0.5rem;
119 color: var(--ink-muted, var(--ink-soft));
120 font-size: 0.85rem;
121}
122
123.search-result-snippet {
124 margin: 0;
125 color: var(--ink-soft);
126 line-height: 1.5;
127}
128.search-result-snippet mark {
129 background: var(--accent);
130 color: white;
131 padding: 0.05em 0.25em;
132 border-radius: 3px;
133}
134</style>
Note: See TracBrowser for help on using the repository browser.