Skip to content

Commit 521128d

Browse files
Refactor reCAPTCHA integration on landing page
Extracted reCAPTCHA site key and script into a dedicated component for better maintainability. Updated landing and waitlist sections to use the new RecaptchaScript and recaptchaSiteKey exports.
1 parent b534907 commit 521128d

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

codegen/html.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { LandingPage } from "#/components/landing_page/mod.ts";
2+
import { CareersPage } from "#/components/careers_page/mod.ts";
23
import { aliases, posts, topics } from "#/components/blog_page/data.ts";
34
import { toTopicID } from "#/components/blog_page/posts.ts";
45
import { BlogPage } from "#/components/blog_page/blog_page.tsx";
@@ -12,6 +13,9 @@ import { renderPostImageResponse } from "#/codegen/og.tsx";
1213
export async function generateHTML(directory: string) {
1314
await Deno.writeTextFile(`${directory}/index.html`, <LandingPage />);
1415

16+
await Deno.mkdir(`${directory}/careers`, { recursive: true });
17+
await Deno.writeTextFile(`${directory}/careers/index.html`, <CareersPage />);
18+
1519
await Deno.mkdir(`${directory}/blog`, { recursive: true });
1620
await Deno.writeTextFile(`${directory}/blog/index.html`, <BlogPage />);
1721

components/landing_page/landing_page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SCRIPT } from "@fartlabs/htx/script";
22
import { featuredPosts } from "#/components/blog_page/data.ts";
33
import { Layout } from "#/components/layout.tsx";
4+
import { RecaptchaScript } from "#/components/recaptcha_script.tsx";
45
import { FAQsSection } from "./faqs_section.tsx";
56
import { FeaturedBlogPostsSection } from "./featured_blog_posts_section.tsx";
67
import { FeaturedGamesSection } from "./featured_games_section.tsx";
@@ -28,7 +29,7 @@ export function LandingPage() {
2829
const scripts = [
2930
<SCRIPT src="https://flackr.github.io/scroll-timeline/dist/scroll-timeline.js" />,
3031
<SCRIPT src="https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js" />,
31-
<SCRIPT src="https://www.google.com/recaptcha/api.js?render=6LfJUC8rAAAAALwhkiZR_6YxdJGF9Q42jOkAXfa1" />,
32+
<RecaptchaScript />,
3233
<ClaimFocusScript />,
3334
];
3435

components/landing_page/waitlist_section.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
SPAN,
1111
} from "@fartlabs/htx";
1212
import { Link, Section } from "@fartlabs/css";
13+
import { recaptchaSiteKey } from "#/components/recaptcha_script.tsx";
1314
import { BorderTube } from "#/components/border-tube.tsx";
1415

1516
const script = `async function submitWaitlistForm(event) {
@@ -28,7 +29,7 @@ const script = `async function submitWaitlistForm(event) {
2829
grecaptcha.ready(() => {
2930
grecaptcha.execute(
3031
// https://github.com/FartLabs/cpu.fartlabs.org/blob/6d1fbcc48efa186db592afb8b207b0ebc06132b4/lib/recaptcha.ts
31-
"6LfJUC8rAAAAALwhkiZR_6YxdJGF9Q42jOkAXfa1",
32+
"${recaptchaSiteKey}",
3233
{ action: "submit" },
3334
).then(resolve, reject);
3435
});

components/recaptcha_script.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { SCRIPT } from "@fartlabs/htx/script";
2+
3+
export const recaptchaSiteKey = "6LfJUC8rAAAAALwhkiZR_6YxdJGF9Q42jOkAXfa1";
4+
5+
export function RecaptchaScript() {
6+
return (
7+
<SCRIPT
8+
src={`https://www.google.com/recaptcha/api.js?render=${recaptchaSiteKey}`}
9+
/>
10+
);
11+
}

0 commit comments

Comments
 (0)