From f14d0cb865368e0b6ae30b906d83c8f16c6a0306 Mon Sep 17 00:00:00 2001 From: Henrik Larsson Date: Fri, 11 Aug 2023 23:37:34 +0200 Subject: [PATCH] Rewrite URLs for app router folders --- .../{category => kategori}/[slug]/page.tsx | 0 .../{product => produkt}/[slug]/page.tsx | 0 app/[locale]/{search => sok}/page.tsx | 0 .../header/desktop-menu/desktop-menu.tsx | 24 ++++++++ components/layout/header/header.tsx | 14 +---- .../modules/blurb-section/blurb-section.tsx | 57 ++++++------------- components/ui/category-card/category-card.tsx | 36 ++++++------ components/ui/product-card/product-card.tsx | 5 +- messages/en.json | 5 ++ messages/sv.json | 5 ++ middleware.ts | 1 - next.config.js | 19 +++++++ 12 files changed, 95 insertions(+), 71 deletions(-) rename app/[locale]/{category => kategori}/[slug]/page.tsx (100%) rename app/[locale]/{product => produkt}/[slug]/page.tsx (100%) rename app/[locale]/{search => sok}/page.tsx (100%) create mode 100644 components/layout/header/desktop-menu/desktop-menu.tsx diff --git a/app/[locale]/category/[slug]/page.tsx b/app/[locale]/kategori/[slug]/page.tsx similarity index 100% rename from app/[locale]/category/[slug]/page.tsx rename to app/[locale]/kategori/[slug]/page.tsx diff --git a/app/[locale]/product/[slug]/page.tsx b/app/[locale]/produkt/[slug]/page.tsx similarity index 100% rename from app/[locale]/product/[slug]/page.tsx rename to app/[locale]/produkt/[slug]/page.tsx diff --git a/app/[locale]/search/page.tsx b/app/[locale]/sok/page.tsx similarity index 100% rename from app/[locale]/search/page.tsx rename to app/[locale]/sok/page.tsx diff --git a/components/layout/header/desktop-menu/desktop-menu.tsx b/components/layout/header/desktop-menu/desktop-menu.tsx new file mode 100644 index 000000000..327a86069 --- /dev/null +++ b/components/layout/header/desktop-menu/desktop-menu.tsx @@ -0,0 +1,24 @@ +'use client'; + +import { useTranslations } from 'next-intl'; +import Link from 'next/link'; + +export default function DesktopMenu({ items, locale }: { items: []; locale: string }) { + const t = useTranslations('routes'); + return ( + + ); +} diff --git a/components/layout/header/header.tsx b/components/layout/header/header.tsx index 8f68d9bfe..b45ea7cec 100644 --- a/components/layout/header/header.tsx +++ b/components/layout/header/header.tsx @@ -3,8 +3,10 @@ import { clientFetch } from '@/lib/sanity/sanity.client'; import Cart from 'components/cart'; import OpenCart from 'components/cart/open-cart'; import Logo from 'components/ui/logo/logo'; + import Link from 'next/link'; import { Suspense } from 'react'; +import DesktopMenu from './desktop-menu/desktop-menu'; import HeaderRoot from './header-root'; import MobileMenuModal from './mobile-menu/modal'; import OpenMobileMenu from './mobile-menu/open-mobile-menu'; @@ -43,17 +45,7 @@ export default async function Header({ locale }: HeaderProps) {
-
    - {mainMenu.map((item: { title: string; slug: string }, i: number) => { - return ( -
  • - - {item.title} - -
  • - ); - })} -
+
diff --git a/components/modules/blurb-section/blurb-section.tsx b/components/modules/blurb-section/blurb-section.tsx index 23d2a50eb..5072b3344 100644 --- a/components/modules/blurb-section/blurb-section.tsx +++ b/components/modules/blurb-section/blurb-section.tsx @@ -1,8 +1,6 @@ -import { Carousel, CarouselItem } from '@/components/modules/carousel/carousel'; import Card from '@/components/ui/card/card'; - +import { cn } from '@/lib/utils'; import Text from 'components/ui/text'; - interface BlurbSectionProps { blurbs: any; title: string; @@ -24,9 +22,7 @@ const BlurbSection = ({ : desktopLayout === '3-column' ? 'lg:grid-cols-3' : 'lg:grid-cols-4'; - - const sliderLayout = desktopLayout === '2-column' ? 2 : desktopLayout === '3-column' ? 3 : 4; - + console.log(imageFormat); return (
{title ? ( @@ -42,52 +38,35 @@ const BlurbSection = ({ )}
{blurbs.map((blurb: object | any, index: number) => { return ( -
+
); })}
- -
- {blurbs && ( - - {blurbs.map((blurb: any, index: number) => ( - - - - ))} - - )} -
); }; diff --git a/components/ui/category-card/category-card.tsx b/components/ui/category-card/category-card.tsx index 923c30e55..b3735de49 100644 --- a/components/ui/category-card/category-card.tsx +++ b/components/ui/category-card/category-card.tsx @@ -1,32 +1,30 @@ -'use client' - -import SanityImage from 'components/ui/sanity-image' -import { cn } from 'lib/utils' -import Link from 'next/link' -import { FC } from 'react' - +'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 { - className?: string - category: any + className?: string; + category: any; } -const placeholderImg = '/product-img-placeholder.svg' - const CategoryCard: FC = ({ category, className }) => { const rootClassName = cn( '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 ( -
-
+
+
= ({ category, className }) => { height={400} sizes="(max-width: 1024px) 50vw, 25vw" /> -
+
{category.title}
- ) -} + ); +}; -export default CategoryCard +export default CategoryCard; diff --git a/components/ui/product-card/product-card.tsx b/components/ui/product-card/product-card.tsx index 7053188d2..85f692916 100644 --- a/components/ui/product-card/product-card.tsx +++ b/components/ui/product-card/product-card.tsx @@ -5,6 +5,7 @@ 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 { @@ -15,10 +16,12 @@ interface Props { const ProductCard: FC = ({ product, className, variant = 'default' }) => { const rootClassName = cn('w-full group relative overflow-hidden', className); + const t = useTranslations('routes'); + const locale = useLocale(); return (