Servizi: foto e "Per saperne di piu'" della stessa card portano allo stesso posto

Erano due espressioni diverse per lo stesso link e sono divergute: su One to One e
Performance Class la foto apriva la scheda del servizio mentre il testo mandava a
/training, quindi la destinazione dipendeva da dove capitava il dito. Adesso
l'indirizzo lo calcola una funzione sola, usata da entrambi. Verificato sulla
pagina renderizzata: sei card, zero link discordanti.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-17 15:38:03 +02:00
parent cbcb533e57
commit a18a505254
+7 -5
View File
@@ -9,9 +9,11 @@ import { t } from '../../lib/content';
const images = import.meta.glob<{ default: ImageMetadata }>('../../assets/img/program-*.jpg', { eager: true }); const images = import.meta.glob<{ default: ImageMetadata }>('../../assets/img/program-*.jpg', { eager: true });
const imgOf = (slug: string) => Object.entries(images).find(([p]) => p.includes(`program-${slug}.`))?.[1]?.default; const imgOf = (slug: string) => Object.entries(images).find(([p]) => p.includes(`program-${slug}.`))?.[1]?.default;
const gridServices = services.filter((p) => p.grid !== false); const gridServices = services.filter((p) => p.grid !== false);
// Questi servizi rimandano alla pagina Training invece che alla scheda di dettaglio // Foto e "Per saperne di più" della stessa card portano allo stesso posto, e lo fanno per
const TRAINING_LINK = new Set(['one-to-one', 'performance-class']); // costruzione: erano due espressioni diverse e sono divergute — su One to One e Performance
const moreHref = (slug: string) => (TRAINING_LINK.has(slug) ? '/training' : `/services/${slug}`); // Class il testo mandava a /training mentre la foto apriva la scheda del servizio, così la
// destinazione dipendeva da dove capitava il dito.
const hrefOf = (slug: string) => `/services/${slug}`;
export const prerender = false; export const prerender = false;
--- ---
<Base title={t('services.meta.title')} description={t('services.meta.description')}> <Base title={t('services.meta.title')} description={t('services.meta.description')}>
@@ -25,7 +27,7 @@ export const prerender = false;
{gridServices.map((p, i) => ( {gridServices.map((p, i) => (
<article class="plist__card" data-reveal style={`--reveal-delay:${((i % 3) * 0.15).toFixed(2)}s`}> <article class="plist__card" data-reveal style={`--reveal-delay:${((i % 3) * 0.15).toFixed(2)}s`}>
{imgOf(p.slug) && ( {imgOf(p.slug) && (
<a class="plist__photo" href={`/services/${p.slug}`}> <a class="plist__photo" href={hrefOf(p.slug)}>
<TImg tag={`service.${p.slug}.image`} src={imgOf(p.slug)!} alt={t(`service.${p.slug}.title`)} widths={[400, 700]} sizes="(max-width:767px) 100vw, 33vw" /> <TImg tag={`service.${p.slug}.image`} src={imgOf(p.slug)!} alt={t(`service.${p.slug}.title`)} widths={[400, 700]} sizes="(max-width:767px) 100vw, 33vw" />
</a> </a>
)} )}
@@ -33,7 +35,7 @@ export const prerender = false;
<T tag={`service.${p.slug}.title`} as="h3" /> <T tag={`service.${p.slug}.title`} as="h3" />
<T tag={`service.${p.slug}.subtitle`} as="p" class="plist__sub" /> <T tag={`service.${p.slug}.subtitle`} as="p" class="plist__sub" />
<T tag={`service.${p.slug}.excerpt`} as="p" /> <T tag={`service.${p.slug}.excerpt`} as="p" />
<a class="plist__more" href={moreHref(p.slug)}>{t('services.card.more-label')}</a> <a class="plist__more" href={hrefOf(p.slug)}>{t('services.card.more-label')}</a>
</div> </div>
</article> </article>
))} ))}