Skip to content

Commit ac0f161

Browse files
committed
fix(portfolio): prevent pre-filter slicing and clarify count usage
1 parent dd8be97 commit ac0f161

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

modules/blox/blox/portfolio/block.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@
5656
{{ $sort_order := cond $sort_ascending "asc" "desc" }}
5757
{{ $query = sort $query $sort_by $sort_order }}
5858

59-
{{/* Store total count before limiting */}}
60-
{{ $total_count := len $query }}
61-
62-
{{/* Limit */}}
63-
{{ $count := partial "functions/coerce_int" (dict "value" (index $content "count") "default" 6 "min" 0) }}
64-
{{ if gt $count 0 }}
65-
{{ $query = first $count $query }}
66-
{{ end }}
67-
6859
{{/* Get filter buttons */}}
6960
{{ $buttons_raw := index $content "buttons" }}
7061
{{ $buttons := slice }}
@@ -86,6 +77,17 @@
8677
{{ end }}
8778
{{ end }}
8879

80+
{{/* Store total count before limiting; keep full set when filtering so buttons work */}}
81+
{{ $total_count := len $query }}
82+
{{ $has_multiple_filters := gt (len $buttons) 1 }}
83+
84+
{{/* Limit (only when not using multiple filters, since Alpine filters client-side) */}}
85+
{{ $count := partial "functions/coerce_int" (dict "value" (index $content "count") "default" 6 "min" 0) }}
86+
{{ if and (gt $count 0) (not $has_multiple_filters) }}
87+
{{ $query = first $count $query }}
88+
{{ end }}
89+
{{ $displayed_count := len $query }}
90+
8991
{{/* Columns */}}
9092
{{ $columns := partial "functions/coerce_int" (dict "value" (index $design "columns") "default" 3 "min" 1 "max" 4) }}
9193
{{ $grid_class := "md:grid-cols-2 lg:grid-cols-3" }}
@@ -390,9 +392,7 @@ <h3 class="text-lg font-bold text-gray-900 dark:text-white mb-2 group-hover:text
390392
{{ $archive := index $content "archive" }}
391393
{{ if not (reflect.IsMap $archive) }}{{ $archive = dict }}{{ end }}
392394
{{ $default_show_archive := false }}
393-
{{ if gt $count 0 }}
394-
{{ $default_show_archive = gt $total_count $count }}
395-
{{ end }}
395+
{{ $default_show_archive = gt $total_count $displayed_count }}
396396
{{ $show_archive_link := partial "functions/coerce_bool" (dict "value" (index $archive "enable") "default" $default_show_archive) }}
397397
{{ if and $show_archive_link $archive_page }}
398398
{{ $archive_link := "" }}

modules/blox/blox/portfolio/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"count": {
3232
"type": "integer",
33-
"description": "Maximum number of projects to display (0 means unlimited)",
33+
"description": "Maximum number of projects to display when no filter buttons are used (0 means unlimited)",
3434
"minimum": 0,
3535
"default": 6
3636
},

0 commit comments

Comments
 (0)