From 44a697ee49dcfcec229be67e2419f46e5383271e Mon Sep 17 00:00:00 2001 From: mauro-balades Date: Mon, 2 Sep 2024 18:43:52 +0200 Subject: [PATCH] feat: Update footer layout, add social media links, and improve styling --- next.config.js | 18 +++--------- src/app/[locale]/layout.tsx | 2 -- src/app/{[locale] => }/feed.xml/route.ts | 0 src/i18n.ts | 35 ++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 16 deletions(-) rename src/app/{[locale] => }/feed.xml/route.ts (100%) create mode 100644 src/i18n.ts diff --git a/next.config.js b/next.config.js index f8b2a17..1a5f198 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,9 @@ const createNextIntlPlugin = require('next-intl/plugin'); const { PHASE_DEVELOPMENT_SERVER } = require('next/constants') - + +const withNextIntl = createNextIntlPlugin(); + /** @type {import('next').NextConfig} */ const nextConfig = (phase, { defaultConfig }) => { const defaultConfigWWW = { @@ -29,18 +31,6 @@ const nextConfig = (phase, { defaultConfig }) => { compiler: { styledComponents: true, }, - webpack: ( - config, - { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack } - ) => { - // Important: return the modified config - return { - output: { - // ... - globalObject: 'this', - }, - } - }, }; if (phase === PHASE_DEVELOPMENT_SERVER) { return { @@ -55,4 +45,4 @@ const nextConfig = (phase, { defaultConfig }) => { }; }; -module.exports = nextConfig; +module.exports = withNextIntl(nextConfig); diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 3cf405b..363eada 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -11,8 +11,6 @@ import { notFound } from "next/navigation"; const inter = Inter({ subsets: ["latin"] }); -export const runtime = 'edge'; - export const metadata: Metadata = { title: "Zen Browser", description: "Download now and experience the Zen Browser", diff --git a/src/app/[locale]/feed.xml/route.ts b/src/app/feed.xml/route.ts similarity index 100% rename from src/app/[locale]/feed.xml/route.ts rename to src/app/feed.xml/route.ts diff --git a/src/i18n.ts b/src/i18n.ts new file mode 100644 index 0000000..8abe4fe --- /dev/null +++ b/src/i18n.ts @@ -0,0 +1,35 @@ +import { getRequestConfig } from "next-intl/server"; +import { headers } from "next/headers"; + +const SUPPORTED_LANGUAGES = ['en', 'de', 'ro']; + +export default getRequestConfig(async () => { + const headersList = headers(); + + const acceptLanguage = headersList.get("accept-language") || "en"; + + const [primaryLanguage] = acceptLanguage + .split(",") + .map((lang) => lang.split(";")[0]) + .map((lang) => lang.toLowerCase()); + + const locale = SUPPORTED_LANGUAGES.includes(primaryLanguage) ? primaryLanguage : 'en'; + + try { + const messages = (await import(`../messages/${locale}.json`)).default; + + return { + locale, + messages, + }; + } catch (error) { + console.error(`Failed to load messages for locale: ${locale}`, error); + + const fallbackMessages = (await import(`../messages/en.json`)).default; + + return { + locale: "en", + messages: fallbackMessages, + }; + } +});