Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/TurnstileWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function loadTurnstileScript(): Promise<void> {
return scriptPromise;
}

export function TurnstileWidget({ action = "default", onToken }: { action?: string; onToken: (token: string) => void }) {
export function TurnstileWidget({ action = "default", invisible = false, onToken }: { action?: string; invisible?: boolean; onToken: (token: string) => void }) {
const id = useId();
const containerRef = useRef<HTMLDivElement>(null);
const siteKey = import.meta.env.VITE_TURNSTILE_SITE_KEY as string | undefined;
Expand All @@ -44,6 +44,7 @@ export function TurnstileWidget({ action = "default", onToken }: { action?: stri
sitekey: siteKey,
theme: "dark",
action,
...(invisible ? { size: "invisible" } : {}),
callback: (token: string) => onToken(token),
"expired-callback": () => onToken(""),
"error-callback": () => onToken(""),
Expand Down
4 changes: 1 addition & 3 deletions src/routes/blog_.$slug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,7 @@ function CommentForm({ postId, onPosted }: { postId: string; onPosted: () => voi
/>
</div>
<Textarea value={text} onChange={(e) => setText(e.target.value)} placeholder="Add a thoughtful comment..." className="mt-3 rounded-xl" rows={3} maxLength={1000} />
<div className="mt-3">
<TurnstileWidget action="comment" onToken={setTurnstileToken} />
</div>
<TurnstileWidget action="comment" invisible onToken={setTurnstileToken} />
<div className="mt-2 flex justify-end">
<Button onClick={submit} disabled={busy || !name.trim() || !email.trim() || !text.trim() || !turnstileToken} className="rounded-lg bg-gradient-to-r from-violet to-electric text-white">
<Send className="mr-1.5 h-3.5 w-3.5" />Post comment
Expand Down
Loading