Skip to content

Commit 17d4f89

Browse files
feat(guides): default the listing to an "All" tab
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0be8243 commit 17d4f89

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

app/guides/guidesClient.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ export default function GuidesClient({
7777
guides: Guide[];
7878
categories: string[];
7979
}) {
80-
const [activeCategory, setActiveCategory] = useState<string>(categories[0]);
80+
const ALL = "All";
81+
const [activeCategory, setActiveCategory] = useState<string>(ALL);
82+
const tabs = [ALL, ...categories];
8183

8284
const featured = useMemo(
8385
() =>
@@ -88,12 +90,14 @@ export default function GuidesClient({
8890
);
8991

9092
const countFor = (category: string) =>
91-
guides.filter((g) => g.category === category).length;
93+
category === ALL
94+
? guides.length
95+
: guides.filter((g) => g.category === category).length;
9296

9397
const visible = useMemo(
9498
() =>
9599
guides
96-
.filter((g) => g.category === activeCategory)
100+
.filter((g) => activeCategory === ALL || g.category === activeCategory)
97101
.sort((a, b) => (a.order ?? 999) - (b.order ?? 999)),
98102
[guides, activeCategory]
99103
);
@@ -169,7 +173,7 @@ export default function GuidesClient({
169173

170174
{/* ================= TABS ================= */}
171175
<div className="mb-12 flex flex-wrap gap-x-8 gap-y-3 border-b border-gray-200">
172-
{categories.map((category) => (
176+
{tabs.map((category) => (
173177
<button
174178
key={category}
175179
onClick={() => setActiveCategory(category)}

0 commit comments

Comments
 (0)