Skip to content

Commit

Permalink
Fix: Fix homepage image
Browse files Browse the repository at this point in the history
  • Loading branch information
whats2000 committed Jul 25, 2024
1 parent 2a40e0e commit adbf4ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/components/common/CarouselSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useAnimateOnScroll from '@/hooks/useAnimateOnScroll.ts';
import { IImageContent } from '@/types/IImageContent.ts';
import getImageUrl from '@/utils/getImageUrl.ts';
import { fadeIn } from '@/styles/animation.ts';
import { STATIC_DATA_API } from '@/constants';

const Section = styled.section`
background-color: #b1dde6;
Expand Down Expand Up @@ -112,19 +113,22 @@ interface CarouselSectionProps {
title: string;
subtitles?: string[];
imageContentsSections: IImageContent[][];
useStaticDataApi?: boolean;
}

/**
* Carousel section component, display multiple carousels as cards, each carousel contains multiple images
* @param title - Section title
* @param subtitles - Section subtitles
* @param imageContentsSections - Array of image content arrays
* @param useStaticDataApi - Flag to use static data api
* @constructor CarouselSection - React Function Component
*/
const CarouselSection: React.FC<CarouselSectionProps> = ({
title,
subtitles: sectionSubtitle = [],
imageContentsSections,
useStaticDataApi = false,
}: CarouselSectionProps) => {
const { ref, animate } = useAnimateOnScroll();

Expand All @@ -145,7 +149,11 @@ const CarouselSection: React.FC<CarouselSectionProps> = ({
<LazyLoadImage
alt={imageContent.title}
effect='blur'
src={getImageUrl(imageContent.imageUrl)}
src={
useStaticDataApi
? `${STATIC_DATA_API}/images/${imageContent.imageUrl}`
: getImageUrl(imageContent.imageUrl)
}
/>
</ImageWrapper>
))}
Expand Down
7 changes: 5 additions & 2 deletions src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ const HomePage = () => {
];

if (redstoneCollection) {
imageContentsSections.push(createSections(redstoneCollection, 'redstone'));
imageContentsSections.push(
createSections(redstoneCollection, 'redstoneCollection'),
);
}

if (architectureCollection) {
imageContentsSections.push(
createSections(architectureCollection, 'architecture'),
createSections(architectureCollection, 'architectureCollection'),
);
}

Expand Down Expand Up @@ -101,6 +103,7 @@ const HomePage = () => {
t('home.carousel.subtitles', { returnObjects: true }) as string[]
}
imageContentsSections={imageContentsSections}
useStaticDataApi={true}
/>
</>
);
Expand Down

0 comments on commit adbf4ed

Please sign in to comment.