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

View File

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

View File

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

View File

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