Skip to content

Commit 63843df

Browse files
committed
feat: better template
1 parent 50c016a commit 63843df

14 files changed

Lines changed: 355 additions & 282 deletions

File tree

apps/web/app/api/profile/x/complete/route.ts

Lines changed: 0 additions & 178 deletions
This file was deleted.

apps/web/app/api/profile/x/connect/route.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { jsonError, jsonSuccess, resolveApiError } from "@/lib/api/response";
22
import { getSessionFromRequest } from "@/lib/auth/session";
33
import { auth } from "@/lib/auth-server";
4-
import { getProfileForUser } from "@/lib/profile/server";
54
import type { ConnectXResponse } from "@/lib/profile/types";
65

76
function readSetCookieHeaders(headers: Headers): string[] {
@@ -28,9 +27,14 @@ export async function POST(request: Request) {
2827
}
2928

3029
try {
31-
const profile = await getProfileForUser(session.user.id);
30+
const linkedAccounts = await auth.api.listUserAccounts({
31+
headers: request.headers,
32+
});
33+
const hasTwitterAccount = linkedAccounts.some(
34+
(account) => account.providerId === "twitter",
35+
);
3236

33-
if (profile.x.linked) {
37+
if (hasTwitterAccount) {
3438
return jsonSuccess<ConnectXResponse>({
3539
url: null,
3640
alreadyLinked: true,
@@ -41,7 +45,7 @@ export async function POST(request: Request) {
4145
headers: request.headers,
4246
body: {
4347
provider: "twitter",
44-
callbackURL: "/api/profile/x/complete",
48+
callbackURL: "/profile",
4549
disableRedirect: true,
4650
},
4751
returnHeaders: true,

apps/web/app/layout.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getSessionFromNextHeaders } from "@/lib/auth/session";
99
import { absoluteUrl, getDefaultOgImagePath, getSiteUrl } from "@/lib/seo";
1010
import "./globals.css";
1111
import { MainProviders } from "./providers";
12+
import Script from "next/script";
1213

1314
const SITE_URL = getSiteUrl();
1415
const DEFAULT_OG_IMAGE_URL = absoluteUrl(getDefaultOgImagePath());
@@ -69,6 +70,12 @@ export default async function RootLayout({
6970
className={`dark ${GeistPixelSquare.variable} ${GeistMono.variable}`}
7071
>
7172
<body className="font-mono antialiased bg-background text-foreground min-h-screen">
73+
<Script
74+
data-website-id="dfid_wmEet4rNZJvfDIEP784LA"
75+
data-domain="claws.supply"
76+
src="https://datafa.st/js/script.js"
77+
strategy="afterInteractive"
78+
/>
7279
<RootProvider theme={{ enabled: false }}>
7380
<MainProviders>
7481
<Navbar user={navbarUser} />

apps/web/app/openclaw/template/[templateSlug]/page.tsx

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ export default async function TemplateDetailPage({ params }: TemplatePageProps)
103103

104104
const category = getCategoryBySlug(detail.template.category);
105105
const relatedTemplates = detail.relatedTemplates;
106+
const discoveryLinks = [
107+
...(category
108+
? [
109+
{
110+
label: `Browse ${category.label}`,
111+
href: categoryPath(category.slug),
112+
},
113+
]
114+
: []),
115+
{
116+
label: "Latest templates",
117+
href: discoveryPath("latest"),
118+
},
119+
{
120+
label: "Popular templates",
121+
href: discoveryPath("popular"),
122+
},
123+
];
106124
const templateUrl = absoluteUrl(templatePath(detail.template.slug));
107125
const productJsonLd = buildTemplateProductJsonLd({
108126
detail,
@@ -127,6 +145,7 @@ export default async function TemplateDetailPage({ params }: TemplatePageProps)
127145
status: templateRow.status,
128146
version: detail.template.version,
129147
}}
148+
discoveryLinks={discoveryLinks}
130149
canManageTemplate={canManageTemplate}
131150
/>
132151
)}
@@ -169,39 +188,10 @@ export default async function TemplateDetailPage({ params }: TemplatePageProps)
169188
</div>
170189
</div>
171190

172-
<p className="max-w-3xl text-sm text-muted-foreground">{detail.template.excerpt}</p>
173-
174-
{detail.template.versionNotes ? (
175-
<div className="border border-border bg-muted/20 p-3 text-xs">
176-
<p className="uppercase tracking-wide text-muted-foreground">What&apos;s New</p>
177-
<p className="mt-1">
178-
{detail.template.version ? `v${detail.template.version}: ` : ""}
179-
{detail.template.versionNotes}
180-
</p>
181-
</div>
182-
) : null}
183-
184-
<div className="flex flex-wrap items-center gap-4 text-xs">
185-
{category ? (
186-
<Link className="hover:underline" href={categoryPath(category.slug)}>
187-
Browse {category.label}
188-
</Link>
189-
) : null}
190-
<Link className="hover:underline" href={discoveryPath("latest")}>
191-
Latest templates
192-
</Link>
193-
<Link className="hover:underline" href={discoveryPath("popular")}>
194-
Popular templates
195-
</Link>
196-
</div>
197-
</header>
198-
199-
<section className="space-y-3">
200-
<h2 className="text-lg">Template Overview</h2>
201191
<p className="max-w-3xl text-sm text-muted-foreground">
202192
{detail.template.description}
203193
</p>
204-
</section>
194+
</header>
205195

206196
{relatedTemplates.length > 0 ? (
207197
<section className="space-y-4">
@@ -214,9 +204,36 @@ export default async function TemplateDetailPage({ params }: TemplatePageProps)
214204
</section>
215205
) : null}
216206

207+
{detail.template.versionNotes ? (
208+
<section>
209+
<details className="border border-border bg-muted/20 p-3 text-xs">
210+
<summary className="cursor-pointer uppercase tracking-wide text-muted-foreground">
211+
What&apos;s New
212+
</summary>
213+
<p className="mt-2">
214+
{detail.template.version ? `v${detail.template.version}: ` : ""}
215+
{detail.template.versionNotes}
216+
</p>
217+
</details>
218+
</section>
219+
) : null}
220+
217221
{templateRow.status === "published" ? (
218222
<TemplateCommentsSection templateSlug={detail.template.slug} />
219223
) : null}
224+
225+
<section className="lg:hidden border border-border bg-background/70 p-4">
226+
<p className="text-[11px] uppercase tracking-wide text-muted-foreground">
227+
Explore
228+
</p>
229+
<div className="mt-3 flex flex-wrap items-center gap-4 text-xs">
230+
{discoveryLinks.map((discoveryLink) => (
231+
<Link key={discoveryLink.href} className="hover:underline" href={discoveryLink.href}>
232+
{discoveryLink.label}
233+
</Link>
234+
))}
235+
</div>
236+
</section>
220237
</OpenClawPageShell>
221238
);
222239
}

apps/web/components/auth/sign-in-form.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ function resolveErrorMessage(error: unknown): string {
2525
return "Unable to sign in right now.";
2626
}
2727

28-
function buildXSyncCallbackUrl(nextPath: string): string {
29-
const params = new URLSearchParams({
30-
next: nextPath,
31-
});
32-
return `/api/profile/x/complete?${params.toString()}`;
33-
}
34-
3528
export function SignInForm({ callbackURL }: SignInFormProps) {
3629
const [email, setEmail] = useState("");
3730
const [password, setPassword] = useState("");
@@ -71,7 +64,7 @@ export function SignInForm({ callbackURL }: SignInFormProps) {
7164

7265
const { error } = await authClient.signIn.social({
7366
provider: "twitter",
74-
callbackURL: buildXSyncCallbackUrl(callbackURL),
67+
callbackURL,
7568
});
7669

7770
if (error) {

apps/web/components/auth/sign-up-form.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ function resolveErrorMessage(error: unknown): string {
2525
return "Unable to create your account right now.";
2626
}
2727

28-
function buildXSyncCallbackUrl(nextPath: string): string {
29-
const params = new URLSearchParams({
30-
next: nextPath,
31-
});
32-
return `/api/profile/x/complete?${params.toString()}`;
33-
}
34-
3528
export function SignUpForm({ callbackURL }: SignUpFormProps) {
3629
const router = useRouter();
3730
const [name, setName] = useState("");
@@ -71,7 +64,7 @@ export function SignUpForm({ callbackURL }: SignUpFormProps) {
7164

7265
const { error } = await authClient.signIn.social({
7366
provider: "twitter",
74-
callbackURL: buildXSyncCallbackUrl(callbackURL),
67+
callbackURL,
7568
});
7669

7770
if (error) {

0 commit comments

Comments
 (0)