blog dynamic

This commit is contained in:
srikanth01234 2026-08-20 22:42:19 +05:30
parent 14c92b0d2f
commit cc1916cb09
4 changed files with 28 additions and 9 deletions

View File

@ -26,8 +26,9 @@ export default function SingleGallery() {
const getEventGallery = useCallback(async () => {
try {
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'https://api.tamilculturewaterloo.org/api';
const res = await axios.get(
`https://api.tamilculturewaterloo.org/api/event-images/event/${eventId}`
`${API_BASE_URL}/event-images/event/${eventId}`
);
const formatted = res.data?.data?.map((img: any) => ({
id: img.id,
@ -109,10 +110,14 @@ export default function SingleGallery() {
onClick={() => handleImageClick(index)}
>
<img
src={image.src}
src={image.src || '/assets/img/all-images/memory/memory-img4.png'}
alt={image.title || `gallery-${index}`}
loading="lazy"
style={{ width: '100%', height: 'auto' }}
onError={(e: any) => {
e.target.onerror = null;
e.target.src = '/assets/img/all-images/memory/memory-img4.png';
}}
/>
</div>
</div>

View File

@ -15,8 +15,9 @@ export default function PhotoGallerySection() {
const getEvents = async () => {
try {
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'https://api.tamilculturewaterloo.org/api';
const eventRes = await axios.get(
'https://api.tamilculturewaterloo.org/api/events/'
`${API_BASE_URL}/events/`
);
const eventsData = eventRes?.data?.data || [];
@ -94,9 +95,13 @@ export default function PhotoGallerySection() {
<div className="img1">
<Link href={`/photo-gallery/single-gallery?id=${event.id}`}>
<img
src={event.eventimageurl}
alt={event.eventtitle}
/>
src={event.eventimageurl || '/assets/img/all-images/memory/memory-img4.png'}
alt={event.eventtitle}
onError={(e) => {
e.target.onerror = null;
e.target.src = '/assets/img/all-images/memory/memory-img4.png';
}}
/>
</Link>
</div>
<div className="content-area">

View File

@ -148,7 +148,7 @@ export default function UpcomingEventSinglePage({ slug: propSlug }) {
}}
>
<img
src={event.image}
src={event.image || '/assets/img/all-images/memory/memory-img4.png'}
alt={event.title}
style={{
width: "100%",
@ -156,6 +156,10 @@ export default function UpcomingEventSinglePage({ slug: propSlug }) {
height: "auto",
objectFit: "contain",
}}
onError={(e) => {
e.target.onerror = null;
e.target.src = '/assets/img/all-images/memory/memory-img4.png';
}}
/>
</div>
</div>

View File

@ -26,8 +26,9 @@ export default function HomePhotoGallerySection() {
const getEvents = async () => {
try {
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'https://api.tamilculturewaterloo.org/api';
const eventRes = await axios.get(
'https://api.tamilculturewaterloo.org/api/events/'
`${API_BASE_URL}/events/`
);
const eventsData = eventRes?.data?.data || [];
@ -117,10 +118,14 @@ export default function HomePhotoGallerySection() {
onClick={() => handleImageClick(index)}
>
<img
src={img.src}
src={img.src || '/assets/img/all-images/memory/memory-img4.png'}
alt={img.alt || `gallery-${index}`}
loading="lazy"
style={{ width: '100%', height: 'auto' }}
onError={(e: any) => {
e.target.onerror = null;
e.target.src = '/assets/img/all-images/memory/memory-img4.png';
}}
/>
<h3>{img?.eventtitle}</h3>
</div>