- {items.map((item) => (
-
+
+ {items.map((item, index) => (
+
))}
);
diff --git a/src/components/media/MediaLibrary.tsx b/src/components/media/MediaLibrary.tsx
index 8842b68..01e3e28 100644
--- a/src/components/media/MediaLibrary.tsx
+++ b/src/components/media/MediaLibrary.tsx
@@ -1,16 +1,16 @@
"use client";
-import { useMemo, useState } from "react";
+import { useState } from "react";
+import { Search } from "lucide-react";
import { MediaGrid } from "@/components/media/MediaCard";
import type { MediaItem, MediaPlatform } from "@/lib/media";
type MediaFilter = "all" | MediaPlatform;
-// Instagram tab removed until Instagram entries exist in lib/media.ts — add
-// `{ label: "Instagram", value: "instagram" }` back once they do.
const FILTERS: readonly { label: string; value: MediaFilter }[] = [
{ label: "All videos", value: "all" },
{ label: "YouTube", value: "youtube" },
+ { label: "Instagram", value: "instagram" },
];
function matchesSearch(item: MediaItem, search: string): boolean {
@@ -23,35 +23,38 @@ function matchesSearch(item: MediaItem, search: string): boolean {
export function MediaLibrary({ items }: { items: readonly MediaItem[] }) {
const [filter, setFilter] = useState
("all");
const [search, setSearch] = useState("");
+ const availableFilters = FILTERS.filter(
+ (option) => option.value === "all" || items.some((item) => item.platform === option.value),
+ );
- const filteredItems = useMemo(
- () =>
- items.filter(
- (item) =>
- (filter === "all" || item.platform === filter) &&
- matchesSearch(item, search),
- ),
- [filter, items, search],
+ const filteredItems = items.filter(
+ (item) =>
+ (filter === "all" || item.platform === filter) && matchesSearch(item, search),
);
const hasActiveFilters = filter !== "all" || search.trim().length > 0;
- const resultLabel = filteredItems.length === 1 ? "video" : "videos";
+ const resultLabel = items.length === 1 ? "video" : "videos";
return (
-
- Browse the library by platform or search the collection.
+
Find a video
+
+ Filter by platform or search the collection.
- {FILTERS.map((option) => {
+ {availableFilters.map((option) => {
const isActive = filter === option.value;
+ const count =
+ option.value === "all"
+ ? items.length
+ : items.filter((item) => item.platform === option.value).length;
return (
setFilter(option.value)}
>
{option.label}
+
+ {count}
+
);
})}
@@ -71,26 +84,29 @@ export function MediaLibrary({ items }: { items: readonly MediaItem[] }) {
- Showing {filteredItems.length} {resultLabel}
+ Showing {filteredItems.length} of {items.length} {resultLabel}
{hasActiveFilters && (
31) {
+ return null;
+ }
+
+ return `${Number(day)} ${MEDIA_MONTHS[monthIndex]} ${year}`;
+}