Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions src/components/AstronomyNews.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@

const PAGE_SIZE = 9;

// Astronomy-themed fallback images for news articles without images
// Using NASA and APOD (Astronomy Picture of the Day) images for better theme consistency
const spaceImages = [
"https://images.unsplash.com/photo-1446776811953-b23d57bd21aa?auto=format&fit=crop&w=800&q=80",
"https://images.unsplash.com/photo-1476610182048-b716b8518aae?auto=format&fit=crop&w=800&q=80",
"https://images.unsplash.com/photo-1447433819943-74a20887a81e?auto=format&fit=crop&w=800&q=80",
"https://images.unsplash.com/photo-1504384308090-c894fdcc538d?auto=format&fit=crop&w=800&q=80",
"https://images.unsplash.com/photo-1444703686981-a3abbc4d4fe3?auto=format&fit=crop&w=800&q=80",
"https://images.unsplash.com/photo-1517976487492-5750f3195933?auto=format&fit=crop&w=800&q=80",
"https://images-assets.nasa.gov/image/PIA12235/PIA12235~orig.jpg", // Saturn
"https://apod.nasa.gov/apod/image/1901/IC405_Abolfath_3952.jpg", // Comet
"https://images-assets.nasa.gov/image/PIA04921/PIA04921~orig.jpg", // Mars
"https://apod.nasa.gov/apod/image/1807/NGC6744-HaLRGBpugh1024.jpg", // Galaxy
"https://images-assets.nasa.gov/image/PIA03606/PIA03606~orig.jpg", // Jupiter
"https://apod.nasa.gov/apod/image/1701/OrionNebula_Hubble_960.jpg", // Orion Nebula
"https://apod.nasa.gov/apod/image/1902/MilkyWayPanorama_Merzlyakov_2000.jpg", // Milky Way
"https://apod.nasa.gov/apod/image/1709/LagoonTrifid_Vargas_1824.jpg", // Nebulae
"https://apod.nasa.gov/apod/image/1611/M42Huygens_4000.jpg", // Orion Nebula detailed
"https://images-assets.nasa.gov/image/PIA23190/PIA23190~orig.jpg", // Earth from space
"https://apod.nasa.gov/apod/image/2008/NGC281_Ayoub_960.jpg", // Pacman Nebula
"https://images-assets.nasa.gov/image/PIA21734/PIA21734~orig.jpg", // James Webb image
];

export default function AstronomyNews() {
Expand Down Expand Up @@ -53,7 +61,7 @@
initialPageParam: 0,
});

const pages = data?.pages || [];

Check warning on line 64 in src/components/AstronomyNews.jsx

View workflow job for this annotation

GitHub Actions / build (18.x)

The 'pages' logical expression could make the dependencies of useMemo Hook (at line 65) change on every render. Move it inside the useMemo callback. Alternatively, wrap the initialization of 'pages' in its own useMemo() Hook

Check warning on line 64 in src/components/AstronomyNews.jsx

View workflow job for this annotation

GitHub Actions / build (20.x)

The 'pages' logical expression could make the dependencies of useMemo Hook (at line 65) change on every render. Move it inside the useMemo callback. Alternatively, wrap the initialization of 'pages' in its own useMemo() Hook
const flattened = useMemo(() => pages.flatMap((p) => p.articles), [pages]);

// 🌌 Assign a consistent random fallback per article
Expand Down Expand Up @@ -114,21 +122,6 @@
}
};

function getRandomAstronomyImage() {
const images = [
"https://images-assets.nasa.gov/image/PIA12235/PIA12235~orig.jpg",
"https://apod.nasa.gov/apod/image/1901/IC405_Abolfath_3952.jpg",
"https://images-assets.nasa.gov/image/PIA04921/PIA04921~orig.jpg",
"https://apod.nasa.gov/apod/image/1807/NGC6744-HaLRGBpugh1024.jpg",
"https://images-assets.nasa.gov/image/PIA03606/PIA03606~orig.jpg",
"https://apod.nasa.gov/apod/image/1701/OrionNebula_Hubble_960.jpg",
"https://apod.nasa.gov/apod/image/1902/MilkyWayPanorama_Merzlyakov_2000.jpg",
"https://apod.nasa.gov/apod/image/1709/LagoonTrifid_Vargas_1824.jpg",
];

const randomIndex = Math.floor(Math.random() * images.length);
return images[randomIndex];
}

return (
<div className="pt-20 md:pt-15 px-0">
Expand Down Expand Up @@ -187,6 +180,7 @@
className="news-image w-full h-56 object-cover rounded-t-2xl opacity-90 transition-transform duration-500 hover:scale-105"
loading="lazy"
onError={(e) => {
// Fallback to astronomy-themed image if original image fails to load
e.target.src = fallbackImages.get(item.id);
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Contributors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default function Contributors() {

{/* Results counter */}
{(activeFilters.length > 0 || activeRepo !== "all") && (
<div className="mb-4 text-center">
<div className="mb-8 text-center">
<p className="text-sm text-white/60">
Showing{" "}
<span className="font-semibold text-emerald-400">
Expand Down
Loading