Skip to content

Commit 5cc9b25

Browse files
authored
Update newsy.html
1 parent 5950d4e commit 5cc9b25

1 file changed

Lines changed: 127 additions & 25 deletions

File tree

‎newsy.html‎

Lines changed: 127 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/* SEKCJA NAGŁÓWKA I WYSZUKIWARKI */
88
.newsy-hero {
99
max-width: 1200px;
10-
margin: 0 auto 40px auto;
10+
margin: 0 auto 30px auto;
1111
display: flex;
1212
flex-direction: column;
1313
gap: 25px;
@@ -31,6 +31,41 @@
3131
color: #fff;
3232
}
3333

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+
3469
/* WYSZUKIWARKA W STYLU TERMINALA */
3570
.search-container {
3671
position: relative;
@@ -82,7 +117,7 @@
82117
background: var(--card-bg);
83118
border: 1px solid var(--border);
84119
border-radius: 12px;
85-
padding: 30px;
120+
padding: 0;
86121
backdrop-filter: blur(10px);
87122
display: flex;
88123
flex-direction: column;
@@ -99,6 +134,7 @@
99134
top: 0; left: 0; width: 4px; height: 100%;
100135
background: var(--accent-contrast);
101136
transition: 0.3s;
137+
z-index: 2;
102138
}
103139

104140
.news-card:hover {
@@ -111,6 +147,22 @@
111147
background: var(--accent-blue);
112148
}
113149

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+
114166
.news-card-meta {
115167
display: flex;
116168
justify-content: space-between;
@@ -160,7 +212,6 @@
160212
font-weight: 700;
161213
}
162214

163-
/* STAN BRAKU WYNIKÓW WYSZUKIWANIA */
164215
.no-results {
165216
grid-column: 1 / -1;
166217
text-align: center;
@@ -196,60 +247,111 @@ <h1>Tech Briefs & News</h1>
196247
</div>
197248
</div>
198249

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+
199258
<div class="newsy-grid" id="newsGrid">
200259
{% 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 }}">
202274
<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>&rarr;</span>
296+
</div>
206297
</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>&rarr;</span>
219298
</div>
220299
</a>
221300
{% endfor %}
222301

223302
<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.
225304
</div>
226305
</div>
227306

228307
<script>
229-
// BŁYSKAWICZNA WYSZUKIWARKA CLIENT-SIDE PO TYTUŁACH
230308
const searchInput = document.getElementById('newsSearch');
309+
const filterButtons = document.querySelectorAll('.filter-btn');
231310
const newsGrid = document.getElementById('newsGrid');
232311
const cards = newsGrid.querySelectorAll('.news-card');
233312
const noResults = document.getElementById('noResults');
234313

235-
searchInput.addEventListener('input', (e) => {
236-
const query = e.target.value.toLowerCase().trim();
314+
let currentCategory = 'all';
315+
let currentQuery = '';
316+
317+
function filterCards() {
237318
let visibleCount = 0;
238319

239320
cards.forEach(card => {
240321
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) {
242328
card.style.display = 'flex';
243329
visibleCount++;
244330
} else {
245331
card.style.display = 'none';
246332
}
247333
});
248334

249-
if(visibleCount === 0) {
335+
if (visibleCount === 0) {
250336
noResults.style.display = 'block';
251337
} else {
252338
noResults.style.display = 'none';
253339
}
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+
});
254356
});
255357
</script>

0 commit comments

Comments
 (0)