diff --git a/public/sitemap.xml b/public/sitemap.xml index 07e6eb9d..16b471ff 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -3,85 +3,85 @@ https://teachlink.app - 2026-07-10 + 2026-08-02 daily 1.0 https://teachlink.app/search - 2026-07-10 + 2026-08-02 weekly 0.8 https://teachlink.app/study-groups - 2026-07-10 + 2026-08-02 weekly 0.7 https://teachlink.app/leaderboard - 2026-07-10 + 2026-08-02 weekly 0.6 https://teachlink.app/certificates - 2026-07-10 + 2026-08-02 weekly 0.5 https://teachlink.app/support - 2026-07-10 + 2026-08-02 monthly 0.4 https://teachlink.app/privacy - 2026-07-10 + 2026-08-02 monthly 0.3 https://teachlink.app/release-notes - 2026-07-10 + 2026-08-02 monthly 0.3 https://teachlink.app/courses/1 - 2026-07-10 + 2026-08-02 weekly 0.8 https://teachlink.app/courses/2 - 2026-07-10 + 2026-08-02 weekly 0.8 https://teachlink.app/courses/3 - 2026-07-10 + 2026-08-02 weekly 0.8 https://teachlink.app/courses/4 - 2026-07-10 + 2026-08-02 weekly 0.8 https://teachlink.app/courses/5 - 2026-07-10 + 2026-08-02 weekly 0.8 https://teachlink.app/courses/6 - 2026-07-10 + 2026-08-02 weekly 0.8 diff --git a/src/app/components/search/SearchResults.tsx b/src/app/components/search/SearchResults.tsx index e9d6a6c4..35cedbb8 100644 --- a/src/app/components/search/SearchResults.tsx +++ b/src/app/components/search/SearchResults.tsx @@ -1,7 +1,7 @@ 'use client'; -import React from 'react'; -import { Star, Clock, User, ArrowRight, SearchX } from 'lucide-react'; +import React, { useState, useEffect, useCallback } from 'react'; +import { Star, Clock, User, ArrowRight, SearchX, ChevronLeft, ChevronRight } from 'lucide-react'; import Image from 'next/image'; import Link from 'next/link'; import clsx from 'clsx'; @@ -27,6 +27,10 @@ interface SearchResultsProps { isLoading?: boolean; sortBy?: string; onSortChange?: (sort: string) => void; + /** Number of cards per page. Defaults to 12. */ + pageSize?: number; + /** Initial page number. Defaults to 1. */ + initialPage?: number; } export const SearchResults: React.FC = ({ @@ -34,7 +38,28 @@ export const SearchResults: React.FC = ({ isLoading = false, sortBy = 'relevance', onSortChange, + pageSize = 12, + initialPage = 1, }) => { + const [currentPage, setCurrentPage] = useState(initialPage); + + // Reset to page 1 whenever the result set changes (new search / filter) + useEffect(() => { + setCurrentPage(1); + }, [results]); + + const totalPages = Math.max(1, Math.ceil(results.length / pageSize)); + const safeCurrentPage = Math.min(currentPage, totalPages); + const startIndex = (safeCurrentPage - 1) * pageSize; + const endIndex = Math.min(startIndex + pageSize, results.length); + const visibleResults = results.slice(startIndex, endIndex); + + const goToPrev = useCallback(() => setCurrentPage((p) => Math.max(1, p - 1)), []); + const goToNext = useCallback( + () => setCurrentPage((p) => Math.min(totalPages, p + 1)), + [totalPages], + ); + if (isLoading) { return (
@@ -92,9 +117,17 @@ export const SearchResults: React.FC = ({ return (
- {/* Sort Controls */} + {/* Sort Controls / Result Count */}
-

{results.length} results found

+

+ Showing{' '} + + {results.length === 0 ? 0 : startIndex + 1}–{endIndex} + {' '} + of{' '} + {results.length}{' '} + results +

{onSortChange && (