Aggiunge menu lingua dropdown e base i18n IT/EN/TH.
Introduce routing multilingua con locale tailandese, selettore lingua a tendina con icone bandiera SVG e gestione chiusura click-outside/Esc, oltre a integrazione Turnstile lato form contatti. Made-with: Cursor
This commit is contained in:
@ -5,6 +5,7 @@ const cf = cta.contactForm;
|
||||
const model = {
|
||||
actionUrl: cf.actionUrl,
|
||||
mailto: cf.mailto,
|
||||
turnstileSiteKey: cf.turnstileSiteKey,
|
||||
notifySubject: cf.notifySubject,
|
||||
successRedirect: cf.successRedirect,
|
||||
fieldName: cf.fieldName,
|
||||
@ -15,6 +16,8 @@ const model = {
|
||||
};
|
||||
const hasFormspree =
|
||||
typeof cf.actionUrl === 'string' && cf.actionUrl.length > 0;
|
||||
const hasTurnstile =
|
||||
typeof cf.turnstileSiteKey === 'string' && cf.turnstileSiteKey.length > 0;
|
||||
const nextUrl =
|
||||
typeof cf.successRedirect === 'string' && cf.successRedirect.length > 0
|
||||
? cf.successRedirect
|
||||
@ -178,6 +181,23 @@ const fieldClass =
|
||||
>
|
||||
</p>
|
||||
|
||||
{
|
||||
hasFormspree && hasTurnstile ? (
|
||||
<div class="pt-1">
|
||||
<div
|
||||
class="cf-turnstile"
|
||||
data-sitekey={cf.turnstileSiteKey}
|
||||
data-theme="dark"
|
||||
data-language="it"
|
||||
data-size="normal"
|
||||
></div>
|
||||
<p class="mt-1.5 text-xs leading-relaxed text-nx-muted">
|
||||
Verifica anti-spam: completa il controllo prima di inviare il messaggio.
|
||||
</p>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
|
||||
<div class="pt-1">
|
||||
<button
|
||||
type="submit"
|
||||
@ -191,6 +211,16 @@ const fieldClass =
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{
|
||||
hasFormspree && hasTurnstile ? (
|
||||
<script
|
||||
src="https://challenges.cloudflare.com/turnstile/v0/api.js"
|
||||
async
|
||||
defer
|
||||
></script>
|
||||
) : null
|
||||
}
|
||||
|
||||
<script>
|
||||
import '../scripts/nx-contact-form.ts';
|
||||
</script>
|
||||
|
||||
@ -17,6 +17,16 @@ const notifySubject =
|
||||
|
||||
const linkClass =
|
||||
'text-sm text-sky-400/90 transition-colors hover:text-sky-300';
|
||||
const path = Astro.url.pathname;
|
||||
const localeMatch = path.match(/^\/(en|th)(\/|$)/);
|
||||
const currentLocale = localeMatch?.[1] ?? 'it';
|
||||
const withLocale = (href: string) => {
|
||||
if (currentLocale === 'it') return href;
|
||||
if (href.startsWith(`/${currentLocale}`)) return href;
|
||||
if (href.startsWith('/#')) return `/${currentLocale}${href}`;
|
||||
if (href.startsWith('/')) return `/${currentLocale}${href}`;
|
||||
return href;
|
||||
};
|
||||
---
|
||||
|
||||
<footer id="site-footer" class="relative z-[1] border-t border-nx-border px-4 py-12 sm:px-6">
|
||||
@ -35,7 +45,7 @@ const linkClass =
|
||||
<ul class="space-y-2.5">
|
||||
{footer.homeNav.map((link) => (
|
||||
<li>
|
||||
<a class={linkClass} href={link.href}>
|
||||
<a class={linkClass} href={withLocale(link.href)}>
|
||||
{link.label}
|
||||
</a>
|
||||
</li>
|
||||
@ -52,7 +62,7 @@ const linkClass =
|
||||
<ul class="space-y-2.5">
|
||||
{footer.legalColumnNav.map((link) => (
|
||||
<li>
|
||||
<a class={linkClass} href={link.href}>
|
||||
<a class={linkClass} href={withLocale(link.href)}>
|
||||
{link.label}
|
||||
</a>
|
||||
</li>
|
||||
@ -101,7 +111,7 @@ const linkClass =
|
||||
{footer.companyNav.map((link) => (
|
||||
<li>
|
||||
{link.href ? (
|
||||
<a class={linkClass} href={link.href}>
|
||||
<a class={linkClass} href={withLocale(link.href)}>
|
||||
{link.label}
|
||||
</a>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user