--- interface Props { stars: number; size: "big" | "small"; } function roundToCustomHalf(value: number) { const whole = Math.floor(value); const decimal = value - whole; if (decimal < 0.25) return whole; if (decimal < 0.75) return whole + 0.5; return whole + 1; } const stars = roundToCustomHalf(Astro.props.stars); const totalStars = 5; ---
{Array.from({ length: totalStars }).map((_, i) => { const starValue = i + 1; let type = "empty"; if (stars >= starValue) { type = "full"; } else if (stars >= starValue - 0.5) { type = "half"; } return ( {type === "full" && ( )} {type === "half" && ( <> )} {type === "empty" && ( )} ); })}