|
7 | 7 | /* SEKCJA NAGŁÓWKA I WYSZUKIWARKI */ |
8 | 8 | .newsy-hero { |
9 | 9 | max-width: 1200px; |
10 | | - margin: 0 auto 40px auto; |
| 10 | + margin: 0 auto 30px auto; |
11 | 11 | display: flex; |
12 | 12 | flex-direction: column; |
13 | 13 | gap: 25px; |
|
31 | 31 | color: #fff; |
32 | 32 | } |
33 | 33 |
|
| 34 | + /* PASEK FILTRÓW KATEGORII (W STYLU PORTALU) */ |
| 35 | + .newsy-filters { |
| 36 | + max-width: 1200px; |
| 37 | + margin: 0 auto 30px auto; |
| 38 | + display: flex; |
| 39 | + gap: 12px; |
| 40 | + flex-wrap: wrap; |
| 41 | + } |
| 42 | + |
| 43 | + .filter-btn { |
| 44 | + background: rgba(255, 255, 255, 0.03); |
| 45 | + border: 1px solid var(--border); |
| 46 | + color: var(--text-muted); |
| 47 | + padding: 8px 16px; |
| 48 | + border-radius: 6px; |
| 49 | + font-family: 'JetBrains Mono', monospace; |
| 50 | + font-size: 0.8rem; |
| 51 | + font-weight: 700; |
| 52 | + cursor: pointer; |
| 53 | + transition: 0.2s; |
| 54 | + text-transform: uppercase; |
| 55 | + } |
| 56 | + |
| 57 | + .filter-btn:hover { |
| 58 | + border-color: var(--accent-blue); |
| 59 | + color: #fff; |
| 60 | + background: rgba(0, 210, 255, 0.05); |
| 61 | + } |
| 62 | + |
| 63 | + .filter-btn.active { |
| 64 | + background: var(--accent-blue); |
| 65 | + border-color: var(--accent-blue); |
| 66 | + color: #0f172a; |
| 67 | + } |
| 68 | + |
34 | 69 | /* WYSZUKIWARKA W STYLU TERMINALA */ |
35 | 70 | .search-container { |
36 | 71 | position: relative; |
|
82 | 117 | background: var(--card-bg); |
83 | 118 | border: 1px solid var(--border); |
84 | 119 | border-radius: 12px; |
85 | | - padding: 30px; |
| 120 | + padding: 0; |
86 | 121 | backdrop-filter: blur(10px); |
87 | 122 | display: flex; |
88 | 123 | flex-direction: column; |
|
99 | 134 | top: 0; left: 0; width: 4px; height: 100%; |
100 | 135 | background: var(--accent-contrast); |
101 | 136 | transition: 0.3s; |
| 137 | + z-index: 2; |
102 | 138 | } |
103 | 139 |
|
104 | 140 | .news-card:hover { |
|
111 | 147 | background: var(--accent-blue); |
112 | 148 | } |
113 | 149 |
|
| 150 | + .news-card-thumb { |
| 151 | + width: 100%; |
| 152 | + height: 200px; |
| 153 | + object-fit: cover; |
| 154 | + border-bottom: 1px solid var(--border); |
| 155 | + display: block; |
| 156 | + } |
| 157 | + |
| 158 | + .news-card-content { |
| 159 | + padding: 30px; |
| 160 | + display: flex; |
| 161 | + flex-direction: column; |
| 162 | + flex-grow: 1; |
| 163 | + justify-content: space-between; |
| 164 | + } |
| 165 | + |
114 | 166 | .news-card-meta { |
115 | 167 | display: flex; |
116 | 168 | justify-content: space-between; |
|
160 | 212 | font-weight: 700; |
161 | 213 | } |
162 | 214 |
|
163 | | - /* STAN BRAKU WYNIKÓW WYSZUKIWANIA */ |
164 | 215 | .no-results { |
165 | 216 | grid-column: 1 / -1; |
166 | 217 | text-align: center; |
@@ -196,60 +247,111 @@ <h1>Tech Briefs & News</h1> |
196 | 247 | </div> |
197 | 248 | </div> |
198 | 249 |
|
| 250 | +<!-- PASEK SZYBKICH FILTRÓW KATEGORII --> |
| 251 | +<div class="newsy-filters" id="categoryFilters"> |
| 252 | + <button class="filter-btn active" data-filter="all">Wszystkie</button> |
| 253 | + <button class="filter-btn" data-filter="hardware">Hardware</button> |
| 254 | + <button class="filter-btn" data-filter="ai">AI / Soft</button> |
| 255 | + <button class="filter-btn" data-filter="homelab">Homelab</button> |
| 256 | +</div> |
| 257 | + |
199 | 258 | <div class="newsy-grid" id="newsGrid"> |
200 | 259 | {% for post in site.newsy %} |
201 | | - <a href="{{ post.url }}" class="news-card" data-title="{{ post.title | downcase }}"> |
| 260 | + {% assign post_thumb = post.image %} |
| 261 | + {% unless post_thumb %} |
| 262 | + {% if post.content contains '<img' %} |
| 263 | + {% assign img_tag = post.content | split: '<img' | second %} |
| 264 | + {% assign img_src = img_tag | split: 'src="' | second | split: '"' | first %} |
| 265 | + {% if img_src %} |
| 266 | + {% assign post_thumb = img_src %} |
| 267 | + {% endif %} |
| 268 | + {% endif %} |
| 269 | + {% endunless %} |
| 270 | + |
| 271 | + {% assign post_cat = post.category | default: "brief" | downcase %} |
| 272 | + |
| 273 | + <a href="{{ post.url }}" class="news-card" data-title="{{ post.title | downcase }}" data-category="{{ post_cat }}"> |
202 | 274 | <div> |
203 | | - <div class="news-card-meta"> |
204 | | - <span class="news-card-tag">[{{ post.category | default: "BRIEF" | upcase }}]</span> |
205 | | - <span>// {{ post.date | date: "%Y.%m.%d" }}</span> |
| 275 | + {% if post_thumb %} |
| 276 | + <img src="{{ post_thumb }}" alt="{{ post.title }}" class="news-card-thumb"> |
| 277 | + {% endif %} |
| 278 | + <div class="news-card-content"> |
| 279 | + <div> |
| 280 | + <div class="news-card-meta"> |
| 281 | + <span class="news-card-tag">[{{ post.category | default: "BRIEF" | upcase }}]</span> |
| 282 | + <span>// {{ post.date | date: "%Y.%m.%d" }}</span> |
| 283 | + </div> |
| 284 | + <h2 class="news-card-title">{{ post.title }}</h2> |
| 285 | + <p class="news-card-excerpt"> |
| 286 | + {% if post.description %} |
| 287 | + {{ post.description }} |
| 288 | + {% else %} |
| 289 | + {{ post.excerpt | strip_html | truncate: 120 }} |
| 290 | + {% endif %} |
| 291 | + </p> |
| 292 | + </div> |
| 293 | + <div class="news-card-footer"> |
| 294 | + <span>// CZYTAJ RAPORT</span> |
| 295 | + <span>→</span> |
| 296 | + </div> |
206 | 297 | </div> |
207 | | - <h2 class="news-card-title">{{ post.title }}</h2> |
208 | | - <p class="news-card-excerpt"> |
209 | | - {% if post.description %} |
210 | | - {{ post.description }} |
211 | | - {% else %} |
212 | | - {{ post.excerpt | strip_html | truncate: 120 }} |
213 | | - {% endif %} |
214 | | - </p> |
215 | | - </div> |
216 | | - <div class="news-card-footer"> |
217 | | - <span>// CZYTAJ RAPORT</span> |
218 | | - <span>→</span> |
219 | 298 | </div> |
220 | 299 | </a> |
221 | 300 | {% endfor %} |
222 | 301 |
|
223 | 302 | <div class="no-results" id="noResults"> |
224 | | - // Brak wpisów pasujących do zapytania w bazie danych. |
| 303 | + // Brak wpisów pasujących do kryteriów wyszukiwania. |
225 | 304 | </div> |
226 | 305 | </div> |
227 | 306 |
|
228 | 307 | <script> |
229 | | - // BŁYSKAWICZNA WYSZUKIWARKA CLIENT-SIDE PO TYTUŁACH |
230 | 308 | const searchInput = document.getElementById('newsSearch'); |
| 309 | + const filterButtons = document.querySelectorAll('.filter-btn'); |
231 | 310 | const newsGrid = document.getElementById('newsGrid'); |
232 | 311 | const cards = newsGrid.querySelectorAll('.news-card'); |
233 | 312 | const noResults = document.getElementById('noResults'); |
234 | 313 |
|
235 | | - searchInput.addEventListener('input', (e) => { |
236 | | - const query = e.target.value.toLowerCase().trim(); |
| 314 | + let currentCategory = 'all'; |
| 315 | + let currentQuery = ''; |
| 316 | + |
| 317 | + function filterCards() { |
237 | 318 | let visibleCount = 0; |
238 | 319 |
|
239 | 320 | cards.forEach(card => { |
240 | 321 | const title = card.getAttribute('data-title'); |
241 | | - if(title.includes(query)) { |
| 322 | + const category = card.getAttribute('data-category'); |
| 323 | + |
| 324 | + const matchesCategory = (currentCategory === 'all' || category.includes(currentCategory)); |
| 325 | + const matchesQuery = title.includes(currentQuery); |
| 326 | + |
| 327 | + if (matchesCategory && matchesQuery) { |
242 | 328 | card.style.display = 'flex'; |
243 | 329 | visibleCount++; |
244 | 330 | } else { |
245 | 331 | card.style.display = 'none'; |
246 | 332 | } |
247 | 333 | }); |
248 | 334 |
|
249 | | - if(visibleCount === 0) { |
| 335 | + if (visibleCount === 0) { |
250 | 336 | noResults.style.display = 'block'; |
251 | 337 | } else { |
252 | 338 | noResults.style.display = 'none'; |
253 | 339 | } |
| 340 | + } |
| 341 | + |
| 342 | + // Nasłuchiwanie wpisywania w wyszukiwarkę |
| 343 | + searchInput.addEventListener('input', (e) => { |
| 344 | + currentQuery = e.target.value.toLowerCase().trim(); |
| 345 | + filterCards(); |
| 346 | + }); |
| 347 | + |
| 348 | + // Nasłuchiwanie kliknięć w przyciski filtrów kategorii |
| 349 | + filterButtons.forEach(btn => { |
| 350 | + btn.addEventListener('click', () => { |
| 351 | + filterButtons.forEach(b => b.classList.remove('active')); |
| 352 | + btn.classList.add('active'); |
| 353 | + currentCategory = btn.getAttribute('data-filter'); |
| 354 | + filterCards(); |
| 355 | + }); |
254 | 356 | }); |
255 | 357 | </script> |
0 commit comments