Files
gw-svelte/src/lib/components/HeroSection.svelte
T

62 lines
1.6 KiB
Svelte
Raw Normal View History

2026-05-02 08:26:18 +12:00
<script lang="ts">
2026-05-02 19:44:45 +12:00
import { getImageMetadata } from '$lib/image-metadata';
2026-05-02 08:26:18 +12:00
import type { HeroContent } from '$lib/types';
export let hero: HeroContent;
$: titleParts = splitTitle(hero.title);
$: mobileTitle = hero.mobileTitle?.trim() || `${hero.title} ${hero.highlight}`.trim();
2026-05-02 19:44:45 +12:00
$: heroImage = getImageMetadata(hero.imageUrl);
2026-05-02 08:26:18 +12:00
function splitTitle(title: string) {
const trimmed = title.trim();
if (trimmed.toLowerCase().endsWith(' in')) {
return {
lead: trimmed.slice(0, -3),
connector: 'in'
};
}
return {
lead: trimmed,
connector: ''
};
}
</script>
<section id="hero">
<div class="hero-inner">
<div class="hero-text">
<h1 class="hero-heading">
<span class="hero-heading-desktop">
<span class="hero-title-main">{titleParts.lead}</span>
{#if titleParts.connector}
<span class="hero-title-connector"> {titleParts.connector}</span>
{/if}
<br />
<span class="hero-title-highlight">{hero.highlight}</span>
</span>
<span class="hero-heading-mobile">{mobileTitle}</span>
</h1>
<div class="hero-buttons">
<a href={hero.primaryCta.href} class="btn btn-yellow">{hero.primaryCta.label}</a>
<a href={hero.secondaryCta.href} class="btn btn-outline">{hero.secondaryCta.label}</a>
</div>
</div>
<div class="hero-img">
<img
src={hero.imageUrl}
alt={hero.imageAlt}
2026-05-02 19:44:45 +12:00
width={heroImage?.width}
height={heroImage?.height}
2026-05-02 08:26:18 +12:00
loading="eager"
fetchpriority="high"
decoding="async"
/>
</div>
</div>
</section>