From 7bf23c6a435f6d1fbcc729df4334c9ca1da2b4fe Mon Sep 17 00:00:00 2001 From: ZeroWave022 <36341766+ZeroWave022@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:38:25 +0200 Subject: [PATCH 1/4] refactor: Rename main route group to default --- src/app/[locale]/{(dashboard) => (default)}/about/page.tsx | 0 src/app/[locale]/{(dashboard) => (default)}/events/page.tsx | 0 src/app/[locale]/{(dashboard) => (default)}/layout.tsx | 0 .../[locale]/{(dashboard) => (default)}/news/(header)/layout.tsx | 0 .../[locale]/{(dashboard) => (default)}/news/(header)/loading.tsx | 0 .../[locale]/{(dashboard) => (default)}/news/(header)/page.tsx | 0 .../[locale]/{(dashboard) => (default)}/news/[article]/page.tsx | 0 src/app/[locale]/{(dashboard) => (default)}/page.tsx | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename src/app/[locale]/{(dashboard) => (default)}/about/page.tsx (100%) rename src/app/[locale]/{(dashboard) => (default)}/events/page.tsx (100%) rename src/app/[locale]/{(dashboard) => (default)}/layout.tsx (100%) rename src/app/[locale]/{(dashboard) => (default)}/news/(header)/layout.tsx (100%) rename src/app/[locale]/{(dashboard) => (default)}/news/(header)/loading.tsx (100%) rename src/app/[locale]/{(dashboard) => (default)}/news/(header)/page.tsx (100%) rename src/app/[locale]/{(dashboard) => (default)}/news/[article]/page.tsx (100%) rename src/app/[locale]/{(dashboard) => (default)}/page.tsx (100%) diff --git a/src/app/[locale]/(dashboard)/about/page.tsx b/src/app/[locale]/(default)/about/page.tsx similarity index 100% rename from src/app/[locale]/(dashboard)/about/page.tsx rename to src/app/[locale]/(default)/about/page.tsx diff --git a/src/app/[locale]/(dashboard)/events/page.tsx b/src/app/[locale]/(default)/events/page.tsx similarity index 100% rename from src/app/[locale]/(dashboard)/events/page.tsx rename to src/app/[locale]/(default)/events/page.tsx diff --git a/src/app/[locale]/(dashboard)/layout.tsx b/src/app/[locale]/(default)/layout.tsx similarity index 100% rename from src/app/[locale]/(dashboard)/layout.tsx rename to src/app/[locale]/(default)/layout.tsx diff --git a/src/app/[locale]/(dashboard)/news/(header)/layout.tsx b/src/app/[locale]/(default)/news/(header)/layout.tsx similarity index 100% rename from src/app/[locale]/(dashboard)/news/(header)/layout.tsx rename to src/app/[locale]/(default)/news/(header)/layout.tsx diff --git a/src/app/[locale]/(dashboard)/news/(header)/loading.tsx b/src/app/[locale]/(default)/news/(header)/loading.tsx similarity index 100% rename from src/app/[locale]/(dashboard)/news/(header)/loading.tsx rename to src/app/[locale]/(default)/news/(header)/loading.tsx diff --git a/src/app/[locale]/(dashboard)/news/(header)/page.tsx b/src/app/[locale]/(default)/news/(header)/page.tsx similarity index 100% rename from src/app/[locale]/(dashboard)/news/(header)/page.tsx rename to src/app/[locale]/(default)/news/(header)/page.tsx diff --git a/src/app/[locale]/(dashboard)/news/[article]/page.tsx b/src/app/[locale]/(default)/news/[article]/page.tsx similarity index 100% rename from src/app/[locale]/(dashboard)/news/[article]/page.tsx rename to src/app/[locale]/(default)/news/[article]/page.tsx diff --git a/src/app/[locale]/(dashboard)/page.tsx b/src/app/[locale]/(default)/page.tsx similarity index 100% rename from src/app/[locale]/(dashboard)/page.tsx rename to src/app/[locale]/(default)/page.tsx From 4c0fdb4f82ed5baaaca07c5802dc2187a180a825 Mon Sep 17 00:00:00 2001 From: ZeroWave022 <36341766+ZeroWave022@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:45:19 +0200 Subject: [PATCH 2/4] refactor: All page components should end with Page --- src/app/[locale]/(default)/about/page.tsx | 2 +- src/app/[locale]/(default)/events/page.tsx | 2 +- src/app/[locale]/(default)/news/(header)/page.tsx | 2 +- src/app/[locale]/(default)/news/[article]/page.tsx | 2 +- src/app/[locale]/(default)/page.tsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/[locale]/(default)/about/page.tsx b/src/app/[locale]/(default)/about/page.tsx index e6f0dae..a16200f 100644 --- a/src/app/[locale]/(default)/about/page.tsx +++ b/src/app/[locale]/(default)/about/page.tsx @@ -12,7 +12,7 @@ export async function generateMetadata({ }; } -export default function About({ +export default function AboutPage({ params: { locale }, }: { params: { locale: string }; diff --git a/src/app/[locale]/(default)/events/page.tsx b/src/app/[locale]/(default)/events/page.tsx index 06f2b35..1477014 100644 --- a/src/app/[locale]/(default)/events/page.tsx +++ b/src/app/[locale]/(default)/events/page.tsx @@ -12,7 +12,7 @@ export async function generateMetadata({ }; } -export default function Events({ +export default function EventsPage({ params: { locale }, }: { params: { locale: string }; diff --git a/src/app/[locale]/(default)/news/(header)/page.tsx b/src/app/[locale]/(default)/news/(header)/page.tsx index 7d30c05..44255c9 100644 --- a/src/app/[locale]/(default)/news/(header)/page.tsx +++ b/src/app/[locale]/(default)/news/(header)/page.tsx @@ -22,7 +22,7 @@ export async function generateMetadata({ }; } -export default function News({ +export default function NewsPage({ params: { locale }, searchParams, }: { diff --git a/src/app/[locale]/(default)/news/[article]/page.tsx b/src/app/[locale]/(default)/news/[article]/page.tsx index c5f7558..0b888b3 100644 --- a/src/app/[locale]/(default)/news/[article]/page.tsx +++ b/src/app/[locale]/(default)/news/[article]/page.tsx @@ -31,7 +31,7 @@ export async function generateMetadata({ }; } -export default function Article({ +export default function ArticlePage({ params, }: { params: { locale: string; article: string }; diff --git a/src/app/[locale]/(default)/page.tsx b/src/app/[locale]/(default)/page.tsx index 2d47237..4d0817f 100644 --- a/src/app/[locale]/(default)/page.tsx +++ b/src/app/[locale]/(default)/page.tsx @@ -1,6 +1,6 @@ import { unstable_setRequestLocale } from 'next-intl/server'; -export default function Home({ +export default function HomePage({ params: { locale }, }: { params: { locale: string }; From 9f678c3f4abe7faa1774c84c090d22da01c59e44 Mon Sep 17 00:00:00 2001 From: ZeroWave022 <36341766+ZeroWave022@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:55:11 +0200 Subject: [PATCH 3/4] refactor: All layout components names should end with Layout --- src/app/[locale]/(default)/layout.tsx | 6 +++--- src/app/[locale]/(default)/news/(header)/layout.tsx | 6 +++--- src/app/[locale]/layout.tsx | 8 ++++---- src/app/layout.tsx | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/app/[locale]/(default)/layout.tsx b/src/app/[locale]/(default)/layout.tsx index ab8e36b..ac6416d 100644 --- a/src/app/[locale]/(default)/layout.tsx +++ b/src/app/[locale]/(default)/layout.tsx @@ -4,15 +4,15 @@ import { Footer } from '@/components/layout/Footer'; import { Header } from '@/components/layout/Header'; import { Main } from '@/components/layout/Main'; -type DashboardProps = { +type DefaultLayoutProps = { children: React.ReactNode; params: { locale: string }; }; -export default function Dashboard({ +export default function DefaultLayout({ children, params: { locale }, -}: DashboardProps) { +}: DefaultLayoutProps) { unstable_setRequestLocale(locale); return ( <> diff --git a/src/app/[locale]/(default)/news/(header)/layout.tsx b/src/app/[locale]/(default)/news/(header)/layout.tsx index 61e0a23..eca5470 100644 --- a/src/app/[locale]/(default)/news/(header)/layout.tsx +++ b/src/app/[locale]/(default)/news/(header)/layout.tsx @@ -6,15 +6,15 @@ import { Link } from '@/lib/navigation'; import { Button } from '@/components/ui/Button'; -type NewsHeaderProps = { +type NewsHeaderLayoutProps = { children: React.ReactNode; params: { locale: string }; }; -export default function NewsHeader({ +export default function NewsHeaderLayout({ children, params: { locale }, -}: NewsHeaderProps) { +}: NewsHeaderLayoutProps) { unstable_setRequestLocale(locale); const t = useTranslations('news'); return ( diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 26d239d..dd826b2 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -7,7 +7,7 @@ import { cx } from '@/lib/utils'; import { RootProviders } from '@/components/providers/RootProviders'; -type LocalelayoutProps = { +type LocaleLayoutProps = { children: React.ReactNode; params: { locale: string }; }; @@ -30,7 +30,7 @@ export function generateStaticParams() { export async function generateMetadata({ params: { locale }, -}: Omit) { +}: Omit) { const t = await getTranslations({ locale, namespace: 'meta' }); return { @@ -71,10 +71,10 @@ export async function generateMetadata({ }; } -export default function Localelayout({ +export default function LocaleLayout({ children, params: { locale }, -}: LocalelayoutProps) { +}: LocaleLayoutProps) { if (!locales.includes(locale)) notFound(); unstable_setRequestLocale(locale); return ( diff --git a/src/app/layout.tsx b/src/app/layout.tsx index b2a2525..c55e460 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,9 +1,9 @@ import '@/styles/globals.css'; -type RootlayoutProps = { +type RootLayoutProps = { children: React.ReactNode; }; -export default function Rootlayout({ children }: RootlayoutProps) { +export default function RootLayout({ children }: RootLayoutProps) { return children; } From 17a24980c3a62ab2d24171e31ec112866ebc8702 Mon Sep 17 00:00:00 2001 From: ZeroWave022 <36341766+ZeroWave022@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:56:32 +0200 Subject: [PATCH 4/4] docs: Add layout and page naming conventions to README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 6ffe7d1..3d62a9c 100644 --- a/README.md +++ b/README.md @@ -86,3 +86,8 @@ We are using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0. - To keep the code as consistent as possible use functions for react components or hooks instead of const variables with arrow function syntax. An exception is when using the forwardRef hook or when creating compound components. - Only use default export for pages or layouts etc. since it is required by Next.js. For everything else use named exports. This is to make it easier to find the components in the codebase or change them without ending up with different names for the same component. - Use `type` instead of `interface` for typescript types. This is to keep the code consistent and to make it easier to read. Aldso `type` is more flexible than `interface` since it can be used for unions and intersections. + +### Naming conventions + +- All layout components should end with Layout. For example: `DefaultLayout`. +- All page components should end with Page to make it clear it is a whole page. For example: `AboutPage`.