Restructured app to work better with localized slugs

This commit is contained in:
Henrik Larsson
2023-08-12 13:55:30 +02:00
parent f14d0cb865
commit 60d1810707
21 changed files with 122 additions and 501 deletions

View File

@@ -1,8 +1,5 @@
'use client';
import SanityImage from 'components/ui/sanity-image';
import { cn } from 'lib/utils';
import { useTranslations } from 'next-intl';
import Link from 'next/link';
import { FC } from 'react';
interface Props {
@@ -15,14 +12,9 @@ const CategoryCard: FC<Props> = ({ category, className }) => {
'w-1/2 min-w-0 grow-0 shrink-0 group relative box-border overflow-hidden transition-transform ease-linear cursor-pointer basis-[50%]',
className
);
const t = useTranslations('routes');
return (
<Link
href={`/${t('category')}/${category.slug}`}
className={rootClassName}
aria-label={category.name}
>
<Link href={`${category.slug}`} className={rootClassName} aria-label={category.name}>
<div className={'flex h-full w-full flex-1 flex-col justify-center'}>
<div className="relative aspect-[3/4] h-full w-full">
<SanityImage

View File

@@ -5,7 +5,6 @@ import type { Product } from '@/lib/storm/product';
import Price from 'components/price';
import Text from 'components/ui/text';
import { cn } from 'lib/utils';
import { useLocale, useTranslations } from 'next-intl';
import Link from 'next/link';
import { FC } from 'react';
interface Props {
@@ -16,12 +15,11 @@ interface Props {
const ProductCard: FC<Props> = ({ product, className, variant = 'default' }) => {
const rootClassName = cn('w-full group relative overflow-hidden', className);
const t = useTranslations('routes');
const locale = useLocale();
console.log(product);
return (
<Link
href={`/${locale}/${t('product')}/${product.slug}`}
href={`${product.slug}`}
className={rootClassName}
aria-label={product.name}
locale={product.locale}