Skip to content

Commit bed1a08

Browse files
authored
docs: website improvements (#2431)
* fix search, build and captcha * add chat * disable welcome email
1 parent 8a7f8cb commit bed1a08

8 files changed

Lines changed: 151 additions & 144 deletions

File tree

docs/.env.local.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ BETTER_AUTH_URL=http://localhost:3000
3030
# SENTRY_AUTH_TOKEN=
3131

3232
NEXT_PUBLIC_BLOCKNOTE_AI_SERVER_API_KEY=
33-
NEXT_PUBLIC_BLOCKNOTE_AI_SERVER_BASE_URL=
33+
NEXT_PUBLIC_BLOCKNOTE_AI_SERVER_BASE_URL=
34+
35+
TURNSTILE_SECRET_KEY=

docs/app/demo/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export default function DemoPage() {
99
</h1>
1010
</div>
1111
<DemoEditor />
12+
<script
13+
async
14+
src="https://heyo.so/embed/script?projectId=6982d5659ff7b5fcebeeff26"
15+
></script>
1216
</main>
1317
);
1418
}

docs/app/pricing/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ export default function Pricing() {
207207
{/* FAQ */}
208208
<FAQ />
209209
</div>
210+
<script
211+
async
212+
src="https://heyo.so/embed/script?projectId=6982d5659ff7b5fcebeeff26"
213+
></script>
210214
</div>
211215
);
212216
}

docs/components/AuthenticationPage.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { authClient, signIn, signUp } from "@/lib/auth-client";
4+
import { Turnstile } from "@marsidev/react-turnstile";
45
import * as Sentry from "@sentry/nextjs";
56
import { track } from "@vercel/analytics";
67
import { useRouter, useSearchParams } from "next/navigation";
@@ -53,6 +54,7 @@ function AuthenticationBox(props: {
5354
const [name, setName] = useState("");
5455
const [email, setEmail] = useState("");
5556
const [password, setPassword] = useState("");
57+
const [turnstileToken, setTurnstileToken] = useState("");
5658

5759
const [signingInState, setSigningInState] = useState<
5860
| { state: "init" }
@@ -130,7 +132,7 @@ function AuthenticationBox(props: {
130132
},
131133
},
132134
);
133-
} else {
135+
} else if (props.variant === "register") {
134136
track("click-sign-up", { type: "email" });
135137
Sentry.captureEvent({
136138
message: "click-sign-up",
@@ -147,6 +149,9 @@ function AuthenticationBox(props: {
147149
callbackURL: "/pricing",
148150
},
149151
{
152+
headers: {
153+
"x-captcha-response": turnstileToken,
154+
},
150155
onSuccess() {
151156
setSigningInState({
152157
state: "done",
@@ -172,6 +177,9 @@ function AuthenticationBox(props: {
172177
},
173178
},
174179
);
180+
} else {
181+
const variant = props.variant satisfies never;
182+
throw new Error("Invalid authentication variant " + variant);
175183
}
176184
};
177185

@@ -213,6 +221,13 @@ function AuthenticationBox(props: {
213221
onChange={(e) => setPassword(e.target.value)}
214222
/>
215223
)}
224+
{props.variant === "register" && (
225+
<Turnstile
226+
// siteKey="1x00000000000000000000AA" testing key
227+
siteKey="0x4AAAAAACYDIU6NEdlm_V7J"
228+
onSuccess={setTurnstileToken}
229+
/>
230+
)}
216231
<button
217232
type="submit"
218233
disabled={signingInState.state === "loading"}
@@ -416,7 +431,7 @@ export default function AuthenticationPage(props: {
416431
</h2>
417432
</div>
418433

419-
<div className="mt-10 sm:mx-auto sm:w-full sm:max-w-[480px]">
434+
<div className="mb-10 mt-10 sm:mx-auto sm:w-full sm:max-w-[480px]">
420435
<div className="bg-fd-accent px-6 py-12 shadow sm:rounded-lg sm:px-12">
421436
<AuthenticationBox variant={props.variant} />
422437
</div>
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1-
import type { ComponentProps } from 'react';
2-
import { cn } from '../../../../lib/fumadocs/cn';
3-
import { type BaseLayoutProps, type NavOptions } from '../shared';
4-
import { Header } from './client';
1+
import type { ComponentProps } from "react";
2+
import { cn } from "../../../../lib/fumadocs/cn";
3+
import { type BaseLayoutProps, type NavOptions } from "../shared";
4+
import { Header } from "./client";
55

66
export interface HomeLayoutProps extends BaseLayoutProps {
77
nav?: Partial<NavOptions>;
88
}
99

10-
export function HomeLayout(props: HomeLayoutProps & ComponentProps<'main'>) {
11-
const { nav = {}, links, githubUrl, i18n, themeSwitch = {}, searchToggle, ...rest } = props;
10+
export function HomeLayout(props: HomeLayoutProps & ComponentProps<"main">) {
11+
const {
12+
nav = {},
13+
links,
14+
githubUrl,
15+
i18n,
16+
themeSwitch = {},
17+
searchToggle,
18+
children,
19+
...rest
20+
} = props;
1221

1322
return (
1423
<main
1524
id="nd-home-layout"
1625
{...rest}
17-
className={cn('flex flex-1 flex-col [--fd-layout-width:1400px]', rest.className)}
26+
className={cn(
27+
"flex flex-1 flex-col [--fd-layout-width:1400px]",
28+
rest.className,
29+
)}
1830
>
1931
{nav.enabled !== false &&
2032
(nav.component ?? (
@@ -27,7 +39,7 @@ export function HomeLayout(props: HomeLayoutProps & ComponentProps<'main'>) {
2739
githubUrl={githubUrl}
2840
/>
2941
))}
30-
{props.children}
42+
{children}
3143
</main>
3244
);
3345
}

docs/lib/auth.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Polar } from "@polar-sh/sdk";
33
import * as Sentry from "@sentry/nextjs";
44
import { betterAuth } from "better-auth";
55
import {
6+
captcha,
67
createAuthMiddleware,
78
customSession,
89
magicLink,
@@ -138,6 +139,11 @@ export const auth = betterAuth({
138139
})
139140
: new Database("./sqlite.db"),
140141
plugins: [
142+
captcha({
143+
provider: "cloudflare-turnstile",
144+
secretKey: process.env.TURNSTILE_SECRET_KEY!,
145+
endpoints: ["/sign-up/email"],
146+
}),
141147
customSession(
142148
async ({ user, session }) => {
143149
// If they are a GitHub sponsor, use that plan type
@@ -273,13 +279,13 @@ export const auth = betterAuth({
273279
// no need to send welcome email
274280
return false;
275281
}
276-
await sendEmail({
277-
to: newSession.user.email,
278-
template: "welcome",
279-
props: {
280-
name: newSession.user.name,
281-
},
282-
});
282+
// await sendEmail({
283+
// to: newSession.user.email,
284+
// template: "welcome",
285+
// props: {
286+
// name: newSession.user.name,
287+
// },
288+
// });
283289
return;
284290
}
285291
}

docs/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dev:email": "next dev",
99
"prebuild:site": "nx run @blocknote/dev-scripts:gen",
1010
"build:site": "fumadocs-mdx && next build",
11-
"start": "serve out",
11+
"start": "next start",
1212
"types:check": "fumadocs-mdx && next typegen && tsc --noEmit",
1313
"postinstall": "fumadocs-mdx",
1414
"lint": "eslint",
@@ -33,7 +33,7 @@
3333
"@blocknote/xl-multi-column": "workspace:*",
3434
"@blocknote/xl-odt-exporter": "workspace:*",
3535
"@blocknote/xl-pdf-exporter": "workspace:*",
36-
"@fumadocs/base-ui": "^16.4.7",
36+
"@fumadocs/base-ui": "16.5.0",
3737
"@liveblocks/client": "3.7.1-tiptap3",
3838
"@liveblocks/react": "3.7.1-tiptap3",
3939
"@liveblocks/react-blocknote": "3.7.1-tiptap3",
@@ -42,6 +42,7 @@
4242
"@mantine/core": "^8.3.11",
4343
"@mantine/hooks": "^8.3.11",
4444
"@mantine/utils": "^6.0.22",
45+
"@marsidev/react-turnstile": "^1.4.2",
4546
"@mui/icons-material": "^5.16.1",
4647
"@mui/material": "^5.16.1",
4748
"@orama/orama": "^3.1.18",
@@ -75,11 +76,11 @@
7576
"better-sqlite3": "^12.6.2",
7677
"class-variance-authority": "^0.7.1",
7778
"framer-motion": "^12.26.2",
78-
"fumadocs-core": "16.4.7",
79-
"fumadocs-mdx": "14.2.5",
79+
"fumadocs-core": "16.5.0",
80+
"fumadocs-mdx": "^14.2.6",
8081
"fumadocs-twoslash": "^3.1.12",
81-
"fumadocs-typescript": "^5.0.1",
82-
"fumadocs-ui": "npm:@fumadocs/base-ui@latest",
82+
"fumadocs-typescript": "^5.1.1",
83+
"fumadocs-ui": "npm:@fumadocs/base-ui@16.5.0",
8384
"lucide-react": "^0.562.0",
8485
"motion": "^12.28.1",
8586
"next": "^16.1.5",

0 commit comments

Comments
 (0)