refactor: restructure landing page with component extraction and fix Server Component hooks
- Extract reusable components: EnterOrSignInButton, paragraphFormatFactory, getProviders - Fix React hooks usage: remove useMemo from async Server Components - Update landing page content for Croatian and English translations - Reorganize terms/policy pages into locale-aware directories - Update PageFooter to use locale-aware links and make component async 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
28
app/lib/getProviders.ts
Normal file
28
app/lib/getProviders.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { authConfig } from "./auth";
|
||||
|
||||
export type AuthProvider = {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
style: {
|
||||
logo: string;
|
||||
bg: string;
|
||||
text: string;
|
||||
};
|
||||
};
|
||||
|
||||
export function getAuthProviders(): AuthProvider[] {
|
||||
const providerKeys: (keyof AuthProvider)[] = ["id", "name", "type", "style"];
|
||||
return authConfig.providers.map((provider) =>
|
||||
getKeyValuesFromObject<AuthProvider>(provider, providerKeys)
|
||||
);
|
||||
}
|
||||
|
||||
export function getKeyValuesFromObject<T>(obj: any, keys: (keyof T)[]): T {
|
||||
return keys.reduce((acc, key) => {
|
||||
if (obj[key]) {
|
||||
acc[key] = obj[key];
|
||||
}
|
||||
return acc;
|
||||
}, {} as T);
|
||||
}
|
||||
13
app/lib/paragraphFormatFactory.tsx
Normal file
13
app/lib/paragraphFormatFactory.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import Link from "next/link";
|
||||
import { ReactNode } from "react"
|
||||
|
||||
export const paragraphFormatFactory = (locale: string) => ({
|
||||
strong: (chunks: ReactNode) => <strong className='text-indigo-400 font-semibold' >{chunks}</strong>,
|
||||
bold: (chunks: ReactNode) => <strong className='text-bold' >{chunks}</strong>,
|
||||
indigo: (chunks: ReactNode) => <span className="text-indigo-400"> {chunks} </span>,
|
||||
p: (chunks: ReactNode) => <p className="p mt-[1em] max-w-[38rem] mx-auto text-justify">{chunks}</p>,
|
||||
disclaimer: (chunks: ReactNode) => <p className="p mt-[1em] max-w-[20rem] mx-auto text-center text-sm text-neutral-500">{chunks}</p>,
|
||||
hint: (chunks: ReactNode) => <span className='text-indigo-400 block'> {chunks}</span>,
|
||||
linkTermsOfService: (chunks: ReactNode) => <Link href={`/${locale}/terms-of-service`} className="hover:underline italic">{chunks}</Link>,
|
||||
linkPrivacyPolicy: (chunks: ReactNode) => <Link href={`/${locale}/privacy-policy`} className="hover:underline italic">{chunks}</Link>
|
||||
});
|
||||
Reference in New Issue
Block a user