From cca3250557bb6631c8f683a17b3362ba0939982d Mon Sep 17 00:00:00 2001 From: Henrik Larsson Date: Wed, 3 May 2023 09:58:35 +0200 Subject: [PATCH] Iterated with translations --- .env.example | 24 +- .npmrc | 1 + app/[locale]/[[...slug]]/page.tsx | 15 + app/{ => [locale]}/api/cart/route.ts | 0 app/{ => [locale]}/api/og/Inter-Bold.ttf | Bin app/{ => [locale]}/api/og/Inter-Regular.ttf | Bin app/{ => [locale]}/api/og/route.tsx | 0 app/{ => [locale]}/error.tsx | 0 app/{ => [locale]}/globals.css | 0 app/[locale]/layout.tsx | 68 + app/[locale]/not-found.tsx | 8 + app/{ => [locale]}/product/[handle]/page.tsx | 0 app/[page]/layout.tsx | 16 - app/[page]/page.tsx | 56 - app/favicon.ico | Bin 535 -> 7406 bytes app/layout.tsx | 45 - app/page.tsx | 37 - app/search/[collection]/page.tsx | 49 - app/search/layout.tsx | 23 - app/search/loading.tsx | 13 - app/search/page.tsx | 41 - components/icons/logo.tsx | 17 +- components/icons/vercel.tsx | 20 - components/layout/footer.tsx | 70 - components/layout/footer/footer.tsx | 31 + components/layout/footer/index.ts | 2 + components/layout/header/header-root.tsx | 8 + components/layout/header/header.tsx | 73 + components/layout/header/index.ts | 2 + components/layout/navbar/index.tsx | 27 +- components/{ => product}/price.tsx | 0 components/{ => ui}/carousel.tsx | 0 components/{ => ui}/loading-dots.tsx | 0 components/ui/locale-switcher.tsx | 30 + components/ui/logo/index.ts | 2 + components/ui/logo/logo.tsx | 21 + components/ui/navigation-menu/index.ts | 2 + .../ui/navigation-menu/navigation-menu.tsx | 123 + helpers/getQueryFromSlug.ts | 45 + i18n-config.ts | 6 + languages.json | 10 + lib/sanity/queries.tsx | 273 ++ lib/sanity/sanity.client.ts | 12 + lib/sanity/sanity.image.ts | 7 + lib/sanity/sanity.preview.ts | 20 + lib/utils.ts | 7 + messages/en.json | 178 + messages/nn.json | 176 + messages/sv.json | 176 + middleware.ts | 14 + next.config.js | 38 +- package.json | 26 +- pnpm-lock.yaml | 4245 +++++++++++++++-- tailwind.config.js | 77 +- 54 files changed, 5406 insertions(+), 728 deletions(-) create mode 100644 .npmrc create mode 100644 app/[locale]/[[...slug]]/page.tsx rename app/{ => [locale]}/api/cart/route.ts (100%) rename app/{ => [locale]}/api/og/Inter-Bold.ttf (100%) rename app/{ => [locale]}/api/og/Inter-Regular.ttf (100%) rename app/{ => [locale]}/api/og/route.tsx (100%) rename app/{ => [locale]}/error.tsx (100%) rename app/{ => [locale]}/globals.css (100%) create mode 100644 app/[locale]/layout.tsx create mode 100644 app/[locale]/not-found.tsx rename app/{ => [locale]}/product/[handle]/page.tsx (100%) delete mode 100644 app/[page]/layout.tsx delete mode 100644 app/[page]/page.tsx delete mode 100644 app/layout.tsx delete mode 100644 app/page.tsx delete mode 100644 app/search/[collection]/page.tsx delete mode 100644 app/search/layout.tsx delete mode 100644 app/search/loading.tsx delete mode 100644 app/search/page.tsx delete mode 100644 components/icons/vercel.tsx delete mode 100644 components/layout/footer.tsx create mode 100644 components/layout/footer/footer.tsx create mode 100644 components/layout/footer/index.ts create mode 100644 components/layout/header/header-root.tsx create mode 100644 components/layout/header/header.tsx create mode 100644 components/layout/header/index.ts rename components/{ => product}/price.tsx (100%) rename components/{ => ui}/carousel.tsx (100%) rename components/{ => ui}/loading-dots.tsx (100%) create mode 100644 components/ui/locale-switcher.tsx create mode 100644 components/ui/logo/index.ts create mode 100644 components/ui/logo/logo.tsx create mode 100644 components/ui/navigation-menu/index.ts create mode 100644 components/ui/navigation-menu/navigation-menu.tsx create mode 100644 helpers/getQueryFromSlug.ts create mode 100644 i18n-config.ts create mode 100644 languages.json create mode 100644 lib/sanity/queries.tsx create mode 100644 lib/sanity/sanity.client.ts create mode 100644 lib/sanity/sanity.image.ts create mode 100644 lib/sanity/sanity.preview.ts create mode 100644 messages/en.json create mode 100644 messages/nn.json create mode 100644 messages/sv.json create mode 100644 middleware.ts diff --git a/.env.example b/.env.example index 088014635..821ecb11f 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,23 @@ -TWITTER_CREATOR="@vercel" -TWITTER_SITE="https://nextjs.org/commerce" -SITE_NAME="Next.js Commerce" +# Created by Vercel CLI +VERCEL="1" +VERCEL_ENV="development" +TURBO_REMOTE_ONLY="true" +NX_DAEMON="false" +VERCEL_URL="" +VERCEL_GIT_PROVIDER="" +VERCEL_GIT_PREVIOUS_SHA="" +VERCEL_GIT_REPO_SLUG="" +VERCEL_GIT_REPO_OWNER="" +VERCEL_GIT_REPO_ID="" +VERCEL_GIT_COMMIT_REF="" +VERCEL_GIT_COMMIT_SHA="" +VERCEL_GIT_COMMIT_MESSAGE="" +VERCEL_GIT_COMMIT_AUTHOR_LOGIN="" +VERCEL_GIT_COMMIT_AUTHOR_NAME="" +VERCEL_GIT_PULL_REQUEST_ID="" + +TWITTER_CREATOR="@kodamera" +TWITTER_SITE="https://kodamera.se" +SITE_NAME="KM Storefront" SHOPIFY_STOREFRONT_ACCESS_TOKEN= SHOPIFY_STORE_DOMAIN= diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..3e775efb0 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +auto-install-peers=true diff --git a/app/[locale]/[[...slug]]/page.tsx b/app/[locale]/[[...slug]]/page.tsx new file mode 100644 index 000000000..733fbffc4 --- /dev/null +++ b/app/[locale]/[[...slug]]/page.tsx @@ -0,0 +1,15 @@ +'use client'; + +import LocaleSwitcher from 'components/ui/locale-switcher'; +import { useTranslations } from 'next-intl'; + +export default function Index() { + const t = useTranslations('Index'); + + return ( +
+

{t('title')}

+ +
+ ) +} \ No newline at end of file diff --git a/app/api/cart/route.ts b/app/[locale]/api/cart/route.ts similarity index 100% rename from app/api/cart/route.ts rename to app/[locale]/api/cart/route.ts diff --git a/app/api/og/Inter-Bold.ttf b/app/[locale]/api/og/Inter-Bold.ttf similarity index 100% rename from app/api/og/Inter-Bold.ttf rename to app/[locale]/api/og/Inter-Bold.ttf diff --git a/app/api/og/Inter-Regular.ttf b/app/[locale]/api/og/Inter-Regular.ttf similarity index 100% rename from app/api/og/Inter-Regular.ttf rename to app/[locale]/api/og/Inter-Regular.ttf diff --git a/app/api/og/route.tsx b/app/[locale]/api/og/route.tsx similarity index 100% rename from app/api/og/route.tsx rename to app/[locale]/api/og/route.tsx diff --git a/app/error.tsx b/app/[locale]/error.tsx similarity index 100% rename from app/error.tsx rename to app/[locale]/error.tsx diff --git a/app/globals.css b/app/[locale]/globals.css similarity index 100% rename from app/globals.css rename to app/[locale]/globals.css diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx new file mode 100644 index 000000000..e0c00f19d --- /dev/null +++ b/app/[locale]/layout.tsx @@ -0,0 +1,68 @@ +import Footer from 'components/layout/footer'; +import Header from 'components/layout/header'; +import { NextIntlClientProvider } from 'next-intl'; +import { Inter } from 'next/font/google'; +import { notFound } from 'next/navigation'; +import { ReactNode } from 'react'; +import './globals.css'; + +const { TWITTER_CREATOR, TWITTER_SITE, SITE_NAME } = process.env; + +export const metadata = { + title: { + default: SITE_NAME, + template: `%s | ${SITE_NAME}` + }, + robots: { + follow: true, + index: true + }, + ...(TWITTER_CREATOR && + TWITTER_SITE && { + twitter: { + card: 'summary_large_image', + creator: TWITTER_CREATOR, + site: TWITTER_SITE + } + }) +}; + +const inter = Inter({ + subsets: ['latin'], + display: 'swap', + variable: '--font-inter' +}); + +export function generateStaticParams() { + return [{locale: 'sv'}, {locale: 'en'}, {locale: 'nn'}]; +} + +interface LocaleLayoutProps { + children: ReactNode + params: { + locale: string + } +} + +export default async function LocaleLayout({children, params: {locale}}: LocaleLayoutProps) { + let messages; + try { + messages = (await import(`../../messages/${locale}.json`)).default; + } catch (error) { + notFound(); + } + + return ( + + + +
+
{children}
+