feat: Implement S3 presigned URL resolution for CMS images across pages and apply minor styling adjustments to the header and hero sections.
This commit is contained in:
@@ -6,7 +6,7 @@ import Link from 'next/link';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { CommonHeader } from '@/components/layout/CommonHeader';
|
||||
import { Footer } from '@/components/layout/Footer';
|
||||
import { cmsService } from '@/services/cms.service';
|
||||
import { cmsService, resolveImageUrl } from '@/services/cms.service';
|
||||
import type {
|
||||
AboutHeroContent,
|
||||
AboutStatsContent,
|
||||
@@ -93,28 +93,43 @@ export default function AboutPage() {
|
||||
const [cta, setCta] = useState<AboutCtaContent>(defaultCta);
|
||||
|
||||
useEffect(() => {
|
||||
cmsService.getPageContent('about').then((sections) => {
|
||||
sections.forEach((s: CmsContentRecord) => {
|
||||
cmsService.getPageContent('about').then(async (sections) => {
|
||||
for (const s of sections) {
|
||||
const c = s.content as Record<string, unknown>;
|
||||
// Only apply CMS content if it has meaningful data; otherwise keep defaults
|
||||
switch (s.sectionKey) {
|
||||
case 'hero':
|
||||
if (c.headline || c.description) setHero(c as unknown as AboutHeroContent);
|
||||
if (c.headline || c.description) {
|
||||
const heroData = c as unknown as AboutHeroContent;
|
||||
heroData.bannerImageUrl = await resolveImageUrl(heroData.bannerImageUrl);
|
||||
setHero(heroData);
|
||||
}
|
||||
break;
|
||||
case 'stats':
|
||||
if (Array.isArray(c.stats) && c.stats.length > 0) setStats(c as unknown as AboutStatsContent);
|
||||
break;
|
||||
case 'features':
|
||||
if (c.badge || (Array.isArray(c.features) && c.features.length > 0)) setFeatures(c as unknown as AboutFeaturesContent);
|
||||
if (c.badge || (Array.isArray(c.features) && c.features.length > 0)) {
|
||||
const featData = c as unknown as AboutFeaturesContent;
|
||||
for (const feat of featData.features) {
|
||||
feat.iconPath = await resolveImageUrl(feat.iconPath);
|
||||
}
|
||||
setFeatures(featData);
|
||||
}
|
||||
break;
|
||||
case 'team':
|
||||
if (Array.isArray(c.members) && c.members.length > 0) setTeam(c as unknown as AboutTeamContent);
|
||||
if (Array.isArray(c.members) && c.members.length > 0) {
|
||||
const teamData = c as unknown as AboutTeamContent;
|
||||
for (const member of teamData.members) {
|
||||
member.imageUrl = await resolveImageUrl(member.imageUrl);
|
||||
}
|
||||
setTeam(teamData);
|
||||
}
|
||||
break;
|
||||
case 'cta':
|
||||
if (c.title || c.description) setCta(c as unknown as AboutCtaContent);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user