From e179aa17431ed5730f75896588a7c68ed9196f1e Mon Sep 17 00:00:00 2001 From: itsfinniii <102350242+itsfinniii@users.noreply.github.com> Date: Wed, 25 Mar 2026 22:14:32 +0100 Subject: [PATCH] Add reviews to the website --- astro/src/components/web/Reviews.astro | 50 +++++++++++++ .../web/subcomponents/StarRating.astro | 71 +++++++++++++++++++ astro/src/components/webpage/Webpage.astro | 2 + 3 files changed, 123 insertions(+) create mode 100644 astro/src/components/web/Reviews.astro create mode 100644 astro/src/components/web/subcomponents/StarRating.astro diff --git a/astro/src/components/web/Reviews.astro b/astro/src/components/web/Reviews.astro new file mode 100644 index 0000000..6d22091 --- /dev/null +++ b/astro/src/components/web/Reviews.astro @@ -0,0 +1,50 @@ +--- +import StarRating from './subcomponents/StarRating.astro'; + +interface Props { + reviews: ReviewListComponent; +} + +const reviews = Astro.props.reviews; + +let totalStars: number = 0; +const totalReviews: number = reviews.reviews.length; + +reviews.reviews.forEach((review) => { + totalStars = totalStars + review.stars; +}); + +const averageStars = Math.round((totalStars / totalReviews) * 10) / 10; +const reviewsToShow = reviews.reviews.slice(0, 5); +--- + +
{averageStars} stars out of {totalReviews} {totalReviews === 1 ? "review" : "reviews"}.
+