New Files
Database Migrations
supabase/migrations/20260118120000_add_view_count_columns.sql- Add view_count columns and increment RPC function
API Routes
src/app/api/views/route.ts- View tracking endpoint with bot detection
Components
src/components/shared/ViewTracker.tsx- Client component for triggering view trackingsrc/components/shared/ViewCount.tsx- Component for displaying view counts with eye icon
Hooks
src/hooks/useViewTracker.ts- Client-side hook for fire-and-forget view tracking
Icons
public/icons/eye.svg- Eye icon for view count display
Documentation
docs/view-tracking-caching.md- Caching strategy documentation for view tracking
Modified Files
Gallery
src/app/gallery/page.tsx- Added "Most viewed this week" and "Trending albums" sections, reduced all limits to 10src/lib/data/gallery.ts- Added getMostViewedPhotosLastWeek function, added short_id to selectsrc/lib/data/albums.ts- Added getMostViewedAlbumsLastWeek function, added view_count to queriessrc/app/api/gallery/albums/route.ts- Added popular sorting support
Detail Pages
src/app/[nickname]/album/[albumSlug]/AlbumContent.tsx- Added ViewTracker and ViewCount displaysrc/components/photo/PhotoPageContent.tsx- Added ViewTracker and ViewCount display
Account & Profile
src/hooks/useAccountForm.ts- Added viewsReceived to AccountStats typesrc/app/api/account/stats/route.ts- Added viewsReceived calculationsrc/components/account/AccountStatsSection.tsx- Added views received displaysrc/lib/data/profiles.ts- Added viewsReceived to getProfileStatssrc/components/shared/ProfileStatsBadges.tsx- Added views received badge
Pagination Components
src/components/gallery/AlbumsPaginated.tsx- Added sorting support (Recent/Popular buttons)
Types
src/database.types.ts- Added view_count columns and increment_view_count RPC function