From 9dc4b6c5b080730a364f7ba829ece2aa28bc18c9 Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Sat, 9 Nov 2024 20:20:53 +0100 Subject: [PATCH] chore: some package updates and minor code fixes --- apps/site/.storybook/__mocks__/navigation.mjs | 6 ---- apps/site/.storybook/main.ts | 6 ++-- apps/site/app/[locale]/[[...path]]/page.tsx | 4 +++ .../__mocks__/client-context.mjs | 0 apps/site/package.json | 2 +- package-lock.json | 30 ++++++++++++------- package.json | 2 +- 7 files changed, 30 insertions(+), 20 deletions(-) delete mode 100644 apps/site/.storybook/__mocks__/navigation.mjs rename apps/site/{.storybook => components}/__mocks__/client-context.mjs (100%) diff --git a/apps/site/.storybook/__mocks__/navigation.mjs b/apps/site/.storybook/__mocks__/navigation.mjs deleted file mode 100644 index dc4f2ca56d285..0000000000000 --- a/apps/site/.storybook/__mocks__/navigation.mjs +++ /dev/null @@ -1,6 +0,0 @@ -export const { Link, redirect, usePathname, useRouter } = { - Link: props => , - redirect: () => void null, - usePathname: () => '', - useRouter: () => ({ push: () => void null, replace: () => void null }), -}; diff --git a/apps/site/.storybook/main.ts b/apps/site/.storybook/main.ts index 46f81a4fa17b8..33db0069c6ee6 100644 --- a/apps/site/.storybook/main.ts +++ b/apps/site/.storybook/main.ts @@ -2,6 +2,8 @@ import { join } from 'node:path'; import type { StorybookConfig } from '@storybook/react-webpack5'; +const mocksFolder = join(__dirname, '../components/__mocks__'); + const config: StorybookConfig = { stories: ['../components/**/*.stories.tsx'], logLevel: 'error', @@ -44,8 +46,8 @@ const config: StorybookConfig = { ...config.resolve, alias: { '@nodevu/core': false, - '@/navigation.mjs': join(__dirname, '__mocks__/navigation.mjs'), - '@/client-context': join(__dirname, '__mocks__/client-context.mjs'), + 'next-intl/navigation': join(mocksFolder, './next-intl.mjs'), + '@/client-context': join(mocksFolder, './client-context.mjs'), '@': join(__dirname, '../'), }, }, diff --git a/apps/site/app/[locale]/[[...path]]/page.tsx b/apps/site/app/[locale]/[[...path]]/page.tsx index 33a711f45d0d8..7137b758beea3 100644 --- a/apps/site/app/[locale]/[[...path]]/page.tsx +++ b/apps/site/app/[locale]/[[...path]]/page.tsx @@ -68,6 +68,9 @@ const getPage: FC = async props => { const { path = [], locale = defaultLocale.code } = await props.params; if (!availableLocaleCodes.includes(locale)) { + // Forces the current locale to be the Default Locale + setRequestLocale(defaultLocale.code); + if (!allLocaleCodes.includes(locale)) { // when the locale is not listed in the locales, return NotFound return notFound(); @@ -75,6 +78,7 @@ const getPage: FC = async props => { // Redirect to the default locale path const pathname = dynamicRouter.getPathname(path); + return redirect(`/${defaultLocale.code}/${pathname}`); } diff --git a/apps/site/.storybook/__mocks__/client-context.mjs b/apps/site/components/__mocks__/client-context.mjs similarity index 100% rename from apps/site/.storybook/__mocks__/client-context.mjs rename to apps/site/components/__mocks__/client-context.mjs diff --git a/apps/site/package.json b/apps/site/package.json index 1c34595936e02..7a21f9afee5d8 100644 --- a/apps/site/package.json +++ b/apps/site/package.json @@ -68,7 +68,7 @@ "glob": "~11.0.0", "gray-matter": "~4.0.3", "next": "15.0.2", - "next-intl": "~3.23.5", + "next-intl": "~3.24.0", "next-themes": "^0.3.0", "postcss": "~8.4.47", "postcss-calc": "~10.0.2", diff --git a/package-lock.json b/package-lock.json index dd3a03f7ef289..9642be1f34ff8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "turbo": "2.2.3" }, "devDependencies": { - "@eslint/js": "~9.10.0", + "@eslint/js": "~9.14.0", "@types/eslint__js": "~8.42.3", "commitizen": "4.3.0", "cz-conventional-changelog": "3.3.0", @@ -66,7 +66,7 @@ "glob": "~11.0.0", "gray-matter": "~4.0.3", "next": "15.0.2", - "next-intl": "~3.23.5", + "next-intl": "~3.24.0", "next-themes": "^0.3.0", "postcss": "~8.4.47", "postcss-calc": "~10.0.2", @@ -1538,9 +1538,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.10.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.10.0.tgz", - "integrity": "sha512-fuXtbiP5GWIn8Fz+LWoOMVf/Jxm+aajZYkhi6CuEm4SxymFM+eUWzbO9qXT+L0iCkL5+KGYMCSGxo686H19S1g==", + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", + "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", "dev": true, "license": "MIT", "engines": { @@ -11768,6 +11768,16 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint/node_modules/@eslint/js": { + "version": "9.10.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.10.0.tgz", + "integrity": "sha512-fuXtbiP5GWIn8Fz+LWoOMVf/Jxm+aajZYkhi6CuEm4SxymFM+eUWzbO9qXT+L0iCkL5+KGYMCSGxo686H19S1g==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/eslint/node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -18338,9 +18348,9 @@ } }, "node_modules/next-intl": { - "version": "3.23.5", - "resolved": "https://registry.npmjs.org/next-intl/-/next-intl-3.23.5.tgz", - "integrity": "sha512-mUuz3JFRdtWpyYEPN8xUXpkn4qEnAADxA5GQjUGobbLY32kWrYfZYs4MrYHAVl2zAAbPcD9oisXF0q8B1ifszA==", + "version": "3.24.0", + "resolved": "https://registry.npmjs.org/next-intl/-/next-intl-3.24.0.tgz", + "integrity": "sha512-48X68QsI92grir2dH1W15yhyVnEjW4c9qmwNt+du+k6mI1QtlE6GyANWHoL4/leTixHv8knZ1y9B/Ys06gmKLg==", "funding": [ { "type": "individual", @@ -18351,11 +18361,11 @@ "dependencies": { "@formatjs/intl-localematcher": "^0.5.4", "negotiator": "^1.0.0", - "use-intl": "^3.23.5" + "use-intl": "^3.24.0" }, "peerDependencies": { "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0" } }, "node_modules/next-themes": { diff --git a/package.json b/package.json index a0af6b96d36d0..c65f88da3dcb2 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "turbo": "2.2.3" }, "devDependencies": { - "@eslint/js": "~9.10.0", + "@eslint/js": "~9.14.0", "@types/eslint__js": "~8.42.3", "commitizen": "4.3.0", "cz-conventional-changelog": "3.3.0",