source: Klonkt/src/views/pages/search.ejs@ 359b9ae

main
Last change on this file since 359b9ae was b94c08e, checked in by roboburr <roboburr@…>, 3 months ago

fix: all site-scoped links use siteUrlBase in hub mode

Follow-up on the feed fix (612b102). The same class of bug was still present in:

  • post.ejs: tag, edit, delete links + comment forms + comment delete + login-next -> now with siteUrlBase prefix
  • bottom-tab.ejs: "Write" FAB (/posts/new)
  • home.ejs: empty-state "Write your first post"
  • profile-sheet.ejs: "New post"
  • search.ejs: search form action

Without the prefix these fell back to the primary site in hub (404 /
wrong site). In solo siteUrlBase is empty -> behavior unchanged.

Co-Authored-By: Claude <noreply@…>

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