move turnstile sitekey import to main page from component
All checks were successful
Generate a build and push to Cloudflare Pages / Build and Deploy to Cloudflare Pages (push) Successful in 1m22s

This commit is contained in:
2026-03-25 19:16:56 -04:00
parent d5c08a3408
commit a90d9565d1
2 changed files with 9 additions and 2 deletions

View File

@@ -5,12 +5,18 @@
import IconCheck from '~icons/lucide/check-circle' import IconCheck from '~icons/lucide/check-circle'
import IconAlertCircle from '~icons/lucide/alert-circle' import IconAlertCircle from '~icons/lucide/alert-circle'
interface Props {
sitekey: string
}
let { sitekey }: Props = $props()
let formState = $state<'idle' | 'submitting' | 'success' | 'error'>('idle') let formState = $state<'idle' | 'submitting' | 'success' | 'error'>('idle')
let errorMessage = $state('') let errorMessage = $state('')
let turnstileWidgetId: string | null = $state(null) let turnstileWidgetId: string | null = $state(null)
let turnstileContainer: HTMLElement let turnstileContainer: HTMLElement
const TURNSTILE_SITEKEY = import.meta.env.PUBLIC_TURNSTILE_SITEKEY const TURNSTILE_SITEKEY = sitekey
onMount(() => { onMount(() => {
// Wait for Turnstile script to load // Wait for Turnstile script to load

View File

@@ -52,6 +52,7 @@ const education: TimelineEntry[] = [
] ]
const featuredProjects = await getFeaturedProjects() const featuredProjects = await getFeaturedProjects()
const currentUrl = Astro.url; const currentUrl = Astro.url;
const turnstileSitekey = import.meta.env.PUBLIC_TURNSTILE_SITEKEY
--- ---
<Layout canonicalUrl={currentUrl}> <Layout canonicalUrl={currentUrl}>
@@ -216,7 +217,7 @@ const currentUrl = Astro.url;
<div class="mt-4"> <div class="mt-4">
<div class="contact-card w-full rounded-xl border bg-card p-6 sm:p-8 shadow-md"> <div class="contact-card w-full rounded-xl border bg-card p-6 sm:p-8 shadow-md">
<div class="mx-auto max-w-2xl"> <div class="mx-auto max-w-2xl">
<ContactForm client:load /> <ContactForm client:load sitekey={turnstileSitekey} />
</div> </div>
</div> </div>
</div> </div>