3131 color : # fff ;
3232 }
3333
34- /* PASEK FILTRÓW KATEGORII */
34+ /* PASEK FILTRÓW KATEGORII (DYNAMICZNY) */
3535 .newsy-filters {
3636 max-width : 1200px ;
3737 margin : 0 auto 30px auto;
@@ -247,16 +247,31 @@ <h1>Tech Briefs & News</h1>
247247 </ div >
248248</ div >
249249
250- <!-- PASEK SZYBKICH FILTRÓW KATEGORII -->
250+ <!-- DYNAMICZNY PASEK FILTRÓW KATEGORII (Pobiera kategorie bezpośrednio z postów) -->
251251< div class ="newsy-filters " id ="categoryFilters ">
252252 < 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 >
253+ {% assign raw_cats = "" %}
254+ {% for post in site.newsy %}
255+ {% if post.categories %}
256+ {% for cat in post.categories %}
257+ {% assign raw_cats = raw_cats | append: cat | append: "," %}
258+ {% endfor %}
259+ {% elsif post.category %}
260+ {% assign raw_cats = raw_cats | append: post.category | append: "," %}
261+ {% endif %}
262+ {% endfor %}
263+ {% assign unique_cats = raw_cats | split: "," | uniq | sort %}
264+
265+ {% for cat in unique_cats %}
266+ {% if cat != "" %}
267+ < button class ="filter-btn " data-filter ="{{ cat | downcase }} "> {{ cat | upcase }}</ button >
268+ {% endif %}
269+ {% endfor %}
256270</ div >
257271
258272< div class ="newsy-grid " id ="newsGrid ">
259273 {% for post in site.newsy %}
274+ <!-- BEZPIECZNE POBIERANIE MINIATURKI (Najpierw zmienna 'image', potem szukanie w tekście) -->
260275 {% assign post_thumb = post.image %}
261276 {% unless post_thumb %}
262277 {% if post.content contains '< img ' %}
@@ -268,17 +283,18 @@ <h1>Tech Briefs & News</h1>
268283 {% endif %}
269284 {% endunless %}
270285
271- {% assign post_cat = post.category | default: "brief" | downcase %}
286+ <!-- OBSŁUGA WIELU KATEGORII W ATRYBUCIE DATA -->
287+ {% capture cat_attr %}{% if post.categories %}{% for c in post.categories %}{{ c | downcase }} {% endfor %}{% else %}{{ post.category | default: "brief" | downcase }}{% endif %}{% endcapture %}
272288
273- < a href ="{{ post.url }} " class ="news-card " data-title ="{{ post.title | downcase }} " data-category ="{{ post_cat }} ">
289+ < a href ="{{ post.url }} " class ="news-card " data-title ="{{ post.title | downcase }} " data-categories ="{{ cat_attr | strip }} ">
274290 < div style ="display: flex; flex-direction: column; height: 100%; ">
275291 {% if post_thumb %}
276292 < img src ="{{ post_thumb }} " alt ="{{ post.title }} " class ="news-card-thumb ">
277293 {% endif %}
278294 < div class ="news-card-content ">
279295 < div >
280296 < div class ="news-card-meta ">
281- < span class ="news-card-tag "> [{{ post.category | default: "BRIEF" | upcase }}]</ span >
297+ < span class ="news-card-tag "> [{{ post.category | default: post.categories.first | default: "BRIEF" | upcase }}]</ span >
282298 < span > // {{ post.date | date: "%Y.%m.%d" }}</ span >
283299 </ div >
284300 < h2 class ="news-card-title "> {{ post.title }}</ h2 >
@@ -319,9 +335,9 @@ <h2 class="news-card-title">{{ post.title }}</h2>
319335
320336 cards . forEach ( card => {
321337 const title = card . getAttribute ( 'data-title' ) ;
322- const category = card . getAttribute ( 'data-category ' ) ;
338+ const categories = card . getAttribute ( 'data-categories ' ) ;
323339
324- const matchesCategory = ( currentCategory === 'all' || category . includes ( currentCategory ) ) ;
340+ const matchesCategory = ( currentCategory === 'all' || categories . includes ( currentCategory ) ) ;
325341 const matchesQuery = title . includes ( currentQuery ) ;
326342
327343 if ( matchesCategory && matchesQuery ) {
0 commit comments