From 911096a58863ede281942c655cc3982c3308c3cb Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sun, 28 Apr 2024 16:02:00 +0200 Subject: [PATCH] chore: move ConfigProvider to layout.tsx, as all pages need it --- src/app/language/[language]/page.tsx | 14 +++++--------- src/app/languages/page.tsx | 12 +++--------- src/app/layout.tsx | 10 ++++++++-- src/app/project/[project]/page.tsx | 14 +++++--------- src/app/projects/page.tsx | 12 +++--------- src/app/string/[project]/[language]/page.tsx | 18 +++++++----------- .../translation/[project]/[language]/page.tsx | 14 +++++--------- 7 files changed, 36 insertions(+), 58 deletions(-) diff --git a/src/app/language/[language]/page.tsx b/src/app/language/[language]/page.tsx index 5cd1bdc..c5affa8 100644 --- a/src/app/language/[language]/page.tsx +++ b/src/app/language/[language]/page.tsx @@ -2,22 +2,18 @@ import React from "react"; import { getNileConfig } from "@/static/NileConfig"; import { LanguageProvider } from "@/providers/LanguageProvider"; import { LayoutCommon } from "@/components/LayoutCommon"; -import { ConfigProvider } from "@/providers/ConfigProvider"; import { Listing } from "./Listing"; export default async function Home({ params }: { params: { language: string } }) { const { language } = params; - const nileConfig = await getNileConfig(); return (
- - - - - - - + + + + +
); } diff --git a/src/app/languages/page.tsx b/src/app/languages/page.tsx index 25a2b3a..831b38b 100644 --- a/src/app/languages/page.tsx +++ b/src/app/languages/page.tsx @@ -1,19 +1,13 @@ import React from "react"; -import { getNileConfig } from "@/static/NileConfig"; import { LayoutCommon } from "@/components/LayoutCommon"; -import { ConfigProvider } from "@/providers/ConfigProvider"; import { Listing } from "./Listing"; export default async function Home() { - const nileConfig = await getNileConfig(); - return (
- - - - - + + +
); } diff --git a/src/app/layout.tsx b/src/app/layout.tsx index b889d6b..5b4e160 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,17 +3,21 @@ import type { Metadata } from "next"; import "./globals.css"; import '@mantine/core/styles.css'; import { ColorSchemeScript, MantineProvider } from '@mantine/core'; +import { getNileConfig } from "@/static/NileConfig"; +import { ConfigProvider } from "@/providers/ConfigProvider"; export const metadata: Metadata = { title: "OpenTTD Web Translator", description: "Translate OpenTTD into your language", }; -export default function RootLayout({ +export default async function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { + const nileConfig = await getNileConfig(); + return ( @@ -21,7 +25,9 @@ export default function RootLayout({ - {children} + + {children} + diff --git a/src/app/project/[project]/page.tsx b/src/app/project/[project]/page.tsx index 91eb3cc..10a37e4 100644 --- a/src/app/project/[project]/page.tsx +++ b/src/app/project/[project]/page.tsx @@ -1,23 +1,19 @@ import React from "react"; import { getNileConfig } from "@/static/NileConfig"; -import { ConfigProvider } from "@/providers/ConfigProvider"; import { ProjectProvider } from "@/providers/ProjectProvider"; import { LayoutCommon } from "@/components/LayoutCommon"; import { Listing } from "./Listing"; export default async function Home({ params }: { params: { project: string } }) { const { project } = params; - const nileConfig = await getNileConfig(); return (
- - - - - - - + + + + +
); } diff --git a/src/app/projects/page.tsx b/src/app/projects/page.tsx index 25a2b3a..831b38b 100644 --- a/src/app/projects/page.tsx +++ b/src/app/projects/page.tsx @@ -1,19 +1,13 @@ import React from "react"; -import { getNileConfig } from "@/static/NileConfig"; import { LayoutCommon } from "@/components/LayoutCommon"; -import { ConfigProvider } from "@/providers/ConfigProvider"; import { Listing } from "./Listing"; export default async function Home() { - const nileConfig = await getNileConfig(); - return (
- - - - - + + +
); } diff --git a/src/app/string/[project]/[language]/page.tsx b/src/app/string/[project]/[language]/page.tsx index 7ed3506..085b132 100644 --- a/src/app/string/[project]/[language]/page.tsx +++ b/src/app/string/[project]/[language]/page.tsx @@ -2,27 +2,23 @@ import React from "react"; import { getNileConfig } from "@/static/NileConfig"; import { LanguageProvider } from "@/providers/LanguageProvider"; import { ValidatorProvider } from "@/providers/ValidatorProvider"; -import { ConfigProvider } from "@/providers/ConfigProvider"; import { ProjectProvider } from "@/providers/ProjectProvider"; import { Listing } from "./Listing"; import { LayoutCommon } from "@/components/LayoutCommon"; export default async function Home({ params }: { params: { project: string, language: string } }) { const { project, language } = params; - const nileConfig = await getNileConfig(); return (
- - - - - - - - - + + + + + + +
); diff --git a/src/app/translation/[project]/[language]/page.tsx b/src/app/translation/[project]/[language]/page.tsx index cf42be1..17aa9b0 100644 --- a/src/app/translation/[project]/[language]/page.tsx +++ b/src/app/translation/[project]/[language]/page.tsx @@ -2,24 +2,20 @@ import React from "react"; import { getNileConfig } from "@/static/NileConfig"; import { LanguageProvider } from "@/providers/LanguageProvider"; import { ValidatorProvider } from "@/providers/ValidatorProvider"; -import { ConfigProvider } from "@/providers/ConfigProvider"; import { ProjectProvider } from "@/providers/ProjectProvider"; import { Listing } from "./Listing"; export default async function Home({ params }: { params: { project: string, language: string } }) { const { project, language } = params; - const nileConfig = await getNileConfig(); return (
- - - - - - - + + + + +
);