refactor: replace Link with LocaleLink in marketing and auth components
- Update `auth-card.tsx` to use `LocaleLink` for logo navigation - Modify `bottom-button.tsx` with a temporary type assertion for href - Replace `Link` with `LocaleLink` in `navbar-mobile.tsx` and `navbar.tsx` - Ensure consistent internationalization routing across components
This commit is contained in:
parent
8199a07674
commit
620cedb8c3
@ -12,6 +12,7 @@ import {
|
||||
import { cn } from "@/lib/utils";
|
||||
import Link from "next/link";
|
||||
import { Logo } from "@/components/logo";
|
||||
import { LocaleLink } from "@/i18n/navigation";
|
||||
|
||||
interface AuthCardProps {
|
||||
children: React.ReactNode;
|
||||
@ -33,9 +34,9 @@ export const AuthCard = ({
|
||||
return (
|
||||
<Card className={cn("shadow-sm border border-border", className)}>
|
||||
<CardHeader className="items-center">
|
||||
<Link href="/" prefetch={false}>
|
||||
<LocaleLink href="/" prefetch={false}>
|
||||
<Logo className="mb-2" />
|
||||
</Link>
|
||||
</LocaleLink>
|
||||
<CardDescription>{headerLabel}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
|
@ -9,10 +9,13 @@ interface BottomButtonProps {
|
||||
label: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: solve this error: href={href as any}
|
||||
*/
|
||||
export const BottomButton = ({ href, label }: BottomButtonProps) => {
|
||||
return (
|
||||
<LocaleLink
|
||||
href={href}
|
||||
href={href as any}
|
||||
className={cn(
|
||||
buttonVariants({ variant: "link", size: "sm" }),
|
||||
"font-normal w-full text-muted-foreground hover:underline underline-offset-4 hover:text-primary"
|
||||
|
@ -19,6 +19,7 @@ import * as React from 'react';
|
||||
import { RemoveScroll } from 'react-remove-scroll';
|
||||
import { ThemeSwitcherHorizontal } from '@/components/layout/theme-switcher-horizontal';
|
||||
import LocaleSelector from '@/components/layout/locale-selector';
|
||||
import { LocaleLink } from '@/i18n/navigation';
|
||||
|
||||
export function NavbarMobile({
|
||||
className,
|
||||
@ -63,10 +64,10 @@ export function NavbarMobile({
|
||||
{...other}
|
||||
>
|
||||
{/* navbar left shows logo */}
|
||||
<Link href={Routes.Root} className="flex items-center gap-2">
|
||||
<LocaleLink href={Routes.Root as any} className="flex items-center gap-2">
|
||||
<Logo />
|
||||
<span className="text-xl font-semibold">{siteConfig.name}</span>
|
||||
</Link>
|
||||
</LocaleLink>
|
||||
|
||||
{/* navbar right shows menu icon */}
|
||||
<Button
|
||||
@ -112,8 +113,8 @@ function MainMobileMenu({ onLinkClicked }: MainMobileMenuProps) {
|
||||
<div className="flex size-full flex-col items-start space-y-4 p-4">
|
||||
{/* action buttons */}
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
<Link
|
||||
href={Routes.Login}
|
||||
<LocaleLink
|
||||
href={Routes.Login as any}
|
||||
onClick={onLinkClicked}
|
||||
className={cn(
|
||||
buttonVariants({
|
||||
@ -124,9 +125,9 @@ function MainMobileMenu({ onLinkClicked }: MainMobileMenuProps) {
|
||||
)}
|
||||
>
|
||||
Log in
|
||||
</Link>
|
||||
<Link
|
||||
href={Routes.Register}
|
||||
</LocaleLink>
|
||||
<LocaleLink
|
||||
href={Routes.Register as any}
|
||||
className={cn(
|
||||
buttonVariants({
|
||||
variant: 'default',
|
||||
@ -137,7 +138,7 @@ function MainMobileMenu({ onLinkClicked }: MainMobileMenuProps) {
|
||||
onClick={onLinkClicked}
|
||||
>
|
||||
Sign up
|
||||
</Link>
|
||||
</LocaleLink>
|
||||
</div>
|
||||
|
||||
{/* main menu */}
|
||||
|
@ -27,6 +27,7 @@ import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { ArrowUpRightIcon } from 'lucide-react';
|
||||
import LocaleSelector from '@/components/layout/locale-selector';
|
||||
import { LocaleLink } from '@/i18n/navigation';
|
||||
|
||||
interface NavBarProps {
|
||||
scroll?: boolean;
|
||||
@ -60,10 +61,10 @@ export function Navbar({ scroll, config }: NavBarProps) {
|
||||
<nav className="hidden lg:flex">
|
||||
{/* logo and name */}
|
||||
<div className="flex items-center">
|
||||
<a href="/" className="flex items-center space-x-2">
|
||||
<LocaleLink href="/" className="flex items-center space-x-2">
|
||||
<Logo />
|
||||
<span className="text-xl font-semibold">{siteConfig.name}</span>
|
||||
</a>
|
||||
</LocaleLink>
|
||||
</div>
|
||||
|
||||
{/* menu links */}
|
||||
@ -173,9 +174,9 @@ export function Navbar({ scroll, config }: NavBarProps) {
|
||||
size="sm"
|
||||
asChild
|
||||
>
|
||||
<a href={Routes.Register}>
|
||||
<LocaleLink href={Routes.Register as any}>
|
||||
Sign up
|
||||
</a>
|
||||
</LocaleLink>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user