diff --git a/app/[locale]/[slug]/page.tsx b/app/[locale]/[slug]/page.tsx index 3200e7fb..a35bb377 100644 --- a/app/[locale]/[slug]/page.tsx +++ b/app/[locale]/[slug]/page.tsx @@ -25,6 +25,7 @@ import { import { getCachedOpenGraphData } from "@/services/ogs"; import type { Metadata } from "next"; import { notFound } from "next/navigation"; +import { connection } from "next/server"; import { Suspense } from "react"; // ----------------------------------------------------------------------------- @@ -34,8 +35,22 @@ import { Suspense } from "react"; export async function generateMetadata({ params, }: { params: Promise<{ slug: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + + // --------------------------------------------------------------------------- + // Services + // --------------------------------------------------------------------------- + const page = await getCachedPage((await params).slug); + // --------------------------------------------------------------------------- + // Return + // --------------------------------------------------------------------------- + return { //@ts-ignore title: page.properties?.Name?.title[0]?.plain_text, @@ -49,20 +64,53 @@ export async function generateMetadata({ // ----------------------------------------------------------------------------- // biome-ignore lint/style/noDefaultExport: +// biome-ignore lint/suspicious/useAwait: export default async function SlugPage({ params, }: { params: Promise<{ locale: string; slug: string }> }) { // --------------------------------------------------------------------------- - // Services + // Render + // --------------------------------------------------------------------------- + + return ( + + + + ); +} + +// ----------------------------------------------------------------------------- +// InnerPage +// ----------------------------------------------------------------------------- + +async function SlugInnerPage({ + params, +}: { params: Promise<{ locale: string; slug: string }> }) { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + + // --------------------------------------------------------------------------- + // Validation // --------------------------------------------------------------------------- // Omit the slug to get the valid uuid const pageId = extractValidUUID((await params).slug); + // --------------------------------------------------------------------------- + // Not Found + // --------------------------------------------------------------------------- + if (!pageId) { - notFound(); + return notFound(); } + // --------------------------------------------------------------------------- + // Services + // --------------------------------------------------------------------------- + // Get the page const page = await getCachedPage(pageId); @@ -148,13 +196,13 @@ export default async function SlugPage({ page.parent.database_id === "badf29d8-7d2f-4e03-b2c5-451a627d8618" && (
- + - + }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- @@ -51,12 +58,12 @@ export async function generateMetadata({ } // ----------------------------------------------------------------------------- -// Page +// Page // ----------------------------------------------------------------------------- // biome-ignore lint/style/noDefaultExport: // biome-ignore lint/suspicious/useAwait: -export default async function AboutPage({ +export default async function AboutInnerPage({ params, }: { params: Promise<{ locale: string }> }) { // --------------------------------------------------------------------------- diff --git a/app/[locale]/blog/page.tsx b/app/[locale]/blog/page.tsx index dfe08b13..8b794d68 100644 --- a/app/[locale]/blog/page.tsx +++ b/app/[locale]/blog/page.tsx @@ -21,6 +21,8 @@ import { } from "@tanstack/react-query"; import type { Metadata } from "next"; import { getTranslations, setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; +import { Suspense } from "react"; // ----------------------------------------------------------------------------- // Metadata @@ -29,6 +31,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server"; export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- @@ -54,6 +62,30 @@ export async function generateMetadata({ export default async function BlogPage({ params, }: { params: Promise<{ locale: string }> }) { + // --------------------------------------------------------------------------- + // Render + // --------------------------------------------------------------------------- + + return ( + + + + ); +} + +// ----------------------------------------------------------------------------- +// Inner Page +// ----------------------------------------------------------------------------- + +async function BlogInnerPage({ + params, +}: { params: Promise<{ locale: string }> }) { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- @@ -61,7 +93,7 @@ export default async function BlogPage({ setRequestLocale((await params).locale); // --------------------------------------------------------------------------- - // Actions + // Query // --------------------------------------------------------------------------- const queryClient = new QueryClient(); @@ -73,6 +105,10 @@ export default async function BlogPage({ initialPageParam: undefined, }); + // --------------------------------------------------------------------------- + // Actions + // --------------------------------------------------------------------------- + const initialData = await getBlogAction((await params).locale); // --------------------------------------------------------------------------- diff --git a/app/[locale]/cause/page.tsx b/app/[locale]/cause/page.tsx index 5c6ffd33..524d0d13 100644 --- a/app/[locale]/cause/page.tsx +++ b/app/[locale]/cause/page.tsx @@ -14,6 +14,7 @@ import type { Metadata } from "next"; import { getTranslations, setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; import SlugPage from "../[slug]/page"; // ----------------------------------------------------------------------------- @@ -33,6 +34,12 @@ const causeSlugs = { export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- diff --git a/app/[locale]/clock/page.tsx b/app/[locale]/clock/page.tsx index d6ddea60..9be192be 100644 --- a/app/[locale]/clock/page.tsx +++ b/app/[locale]/clock/page.tsx @@ -15,6 +15,8 @@ import { Clock } from "@/sections/clock"; import type { Metadata } from "next"; import { getTranslations, setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; +import { Suspense } from "react"; // ----------------------------------------------------------------------------- // Metadata @@ -23,6 +25,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server"; export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- @@ -57,5 +65,9 @@ export default async function ClockPage({ // Render // --------------------------------------------------------------------------- - return ; + return ( + + + + ); } diff --git a/app/[locale]/dashboard/page.tsx b/app/[locale]/dashboard/page.tsx index 4467fc67..e89744e8 100644 --- a/app/[locale]/dashboard/page.tsx +++ b/app/[locale]/dashboard/page.tsx @@ -15,6 +15,7 @@ import { Dashboard } from "@/sections/dashboard"; import type { Metadata } from "next"; import { getTranslations, setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; // ----------------------------------------------------------------------------- // Metadata @@ -23,6 +24,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server"; export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- diff --git a/app/[locale]/[...rest]/page.tsx b/app/[locale]/error.tsx similarity index 88% rename from app/[locale]/[...rest]/page.tsx rename to app/[locale]/error.tsx index ceaa092d..c89cbe11 100644 --- a/app/[locale]/[...rest]/page.tsx +++ b/app/[locale]/error.tsx @@ -12,17 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { notFound } from "next/navigation"; +"use client"; // ----------------------------------------------------------------------------- // Page // ----------------------------------------------------------------------------- // biome-ignore lint/style/noDefaultExport: -export default function CatchAllPage() { +// biome-ignore lint/suspicious/useAwait: +export default async function ErrorPage() { // --------------------------------------------------------------------------- // Render // --------------------------------------------------------------------------- - notFound(); + return null; } diff --git a/app/[locale]/history/page.tsx b/app/[locale]/history/page.tsx index 88aff598..4771dffa 100644 --- a/app/[locale]/history/page.tsx +++ b/app/[locale]/history/page.tsx @@ -15,6 +15,7 @@ import { History } from "@/sections/history"; import type { Metadata } from "next"; import { getTranslations, setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; // ----------------------------------------------------------------------------- // Metadata @@ -23,6 +24,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server"; export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- diff --git a/app/[locale]/journal/page.tsx b/app/[locale]/journal/page.tsx index 75bcb920..d604b4c9 100644 --- a/app/[locale]/journal/page.tsx +++ b/app/[locale]/journal/page.tsx @@ -21,6 +21,8 @@ import { } from "@tanstack/react-query"; import type { Metadata } from "next"; import { getTranslations } from "next-intl/server"; +import { connection } from "next/server"; +import { Suspense } from "react"; // ----------------------------------------------------------------------------- // Metadata @@ -29,6 +31,12 @@ import { getTranslations } from "next-intl/server"; export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- @@ -53,7 +61,29 @@ export async function generateMetadata({ // biome-ignore lint/suspicious/useAwait: export default async function JournalPage() { // --------------------------------------------------------------------------- - // Actions + // Render + // --------------------------------------------------------------------------- + + return ( + + + + ); +} + +// ----------------------------------------------------------------------------- +// Inner Page +// ----------------------------------------------------------------------------- + +async function JournalInnerPage() { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + + // --------------------------------------------------------------------------- + // Query // --------------------------------------------------------------------------- const queryClient = new QueryClient(); @@ -64,6 +94,10 @@ export default async function JournalPage() { initialPageParam: undefined, }); + // --------------------------------------------------------------------------- + // Actions + // --------------------------------------------------------------------------- + const initialData = await getJournalAction(); // --------------------------------------------------------------------------- diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index b9ff0854..88c4391f 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -14,15 +14,16 @@ import { SiteFooter } from "@/components/site-footer"; import { SiteHeader } from "@/components/site-header"; -import { locales } from "@/config"; import { siteConfig } from "@/config/site"; +import { routing } from "@/i18n/routing"; import { NextIntlClientProvider } from "next-intl"; import { getMessages, getTranslations, setRequestLocale, } from "next-intl/server"; -import type { ReactNode } from "react"; +import { connection } from "next/server"; +import { type ReactNode, Suspense } from "react"; // ----------------------------------------------------------------------------- // Props @@ -34,16 +35,26 @@ interface LocaleLayoutProps { } // ----------------------------------------------------------------------------- -// Metadata +// Paths // ----------------------------------------------------------------------------- export function generateStaticParams() { - return locales.map((locale) => ({ locale })); + return routing.locales.map((locale) => ({ locale })); } +// ----------------------------------------------------------------------------- +// Metadata +// ----------------------------------------------------------------------------- + export async function generateMetadata({ params, }: Omit) { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- @@ -63,14 +74,37 @@ export async function generateMetadata({ } // ----------------------------------------------------------------------------- -// Page +// Layout // ----------------------------------------------------------------------------- // biome-ignore lint/style/noDefaultExport: +// biome-ignore lint/suspicious/useAwait: export default async function RootLayout({ children, params, }: LocaleLayoutProps) { + // --------------------------------------------------------------------------- + // Render + // --------------------------------------------------------------------------- + + return ( + + {children} + + ); +} + +// ----------------------------------------------------------------------------- +// Inner Layout +// ----------------------------------------------------------------------------- + +export async function RootInnerLayout({ children, params }: LocaleLayoutProps) { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- diff --git a/app/[locale]/mission/page.tsx b/app/[locale]/mission/page.tsx index ae1627d7..0491ff6b 100644 --- a/app/[locale]/mission/page.tsx +++ b/app/[locale]/mission/page.tsx @@ -14,6 +14,7 @@ import type { Metadata } from "next"; import { getTranslations, setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; import SlugPage from "../[slug]/page"; // ----------------------------------------------------------------------------- @@ -33,6 +34,12 @@ const missionSlugs = { export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- diff --git a/app/[locale]/not-found.tsx b/app/[locale]/not-found.tsx new file mode 100644 index 00000000..c715caf0 --- /dev/null +++ b/app/[locale]/not-found.tsx @@ -0,0 +1,83 @@ +// Copyright 2023-2024 Shun Kakinoki. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import type { Metadata } from "next"; +import { getTranslations } from "next-intl/server"; +import { connection } from "next/server"; +import { Suspense } from "react"; + +// ----------------------------------------------------------------------------- +// Metadata +// ----------------------------------------------------------------------------- + +export async function generateMetadata({ + params, +}: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + + // --------------------------------------------------------------------------- + // i18n + // --------------------------------------------------------------------------- + + const t = await getTranslations({ locale: (await params).locale }); + + // --------------------------------------------------------------------------- + // Return + // --------------------------------------------------------------------------- + + return { + title: t("notFound.title"), + description: t("notFound.description"), + }; +} + +// ----------------------------------------------------------------------------- +// Page +// ----------------------------------------------------------------------------- + +// biome-ignore lint/style/noDefaultExport: +// biome-ignore lint/suspicious/useAwait: +export default async function NotFoundPage() { + // --------------------------------------------------------------------------- + // Render + // --------------------------------------------------------------------------- + + return ( + + + + ); +} + +// ----------------------------------------------------------------------------- +// Inner Page +// ----------------------------------------------------------------------------- + +async function NotFoundInnerPage() { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + + // --------------------------------------------------------------------------- + // Render + // --------------------------------------------------------------------------- + + return
Not Found
; +} diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 1b66fa0c..dfe7b908 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -28,16 +28,42 @@ import { Button } from "@lightdotso/ui/components/button"; import { TwitterLogoIcon } from "@radix-ui/react-icons"; import { ArrowUpRightFromSquareIcon } from "lucide-react"; import { setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; +import { Suspense } from "react"; // ----------------------------------------------------------------------------- // Page // ----------------------------------------------------------------------------- -// biome-ignore lint/style/noDefaultExport: // biome-ignore lint/suspicious/useAwait: +// biome-ignore lint/style/noDefaultExport: export default async function IndexPage({ params, }: { params: Promise<{ locale: string }> }) { + // --------------------------------------------------------------------------- + // Render + // --------------------------------------------------------------------------- + + return ( + + + + ); +} + +// ----------------------------------------------------------------------------- +// InnerPage +// ----------------------------------------------------------------------------- + +async function IndexInnerPage({ + params, +}: { params: Promise<{ locale: string }> }) { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- diff --git a/app/[locale]/posts/page.tsx b/app/[locale]/posts/page.tsx index 3bef41d4..3bedccdc 100644 --- a/app/[locale]/posts/page.tsx +++ b/app/[locale]/posts/page.tsx @@ -21,6 +21,8 @@ import { } from "@tanstack/react-query"; import type { Metadata } from "next"; import { getTranslations } from "next-intl/server"; +import { connection } from "next/server"; +import { Suspense } from "react"; // ----------------------------------------------------------------------------- // Metadata @@ -29,6 +31,12 @@ import { getTranslations } from "next-intl/server"; export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- @@ -49,11 +57,33 @@ export async function generateMetadata({ // Page // ----------------------------------------------------------------------------- -// biome-ignore lint/style/noDefaultExport: // biome-ignore lint/suspicious/useAwait: +// biome-ignore lint/style/noDefaultExport: export default async function PostsPage() { // --------------------------------------------------------------------------- - // Actions + // Render + // --------------------------------------------------------------------------- + + return ( + + + + ); +} + +// ----------------------------------------------------------------------------- +// Inner Page +// ----------------------------------------------------------------------------- + +async function PostsInnerPage() { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + + // --------------------------------------------------------------------------- + // Query // --------------------------------------------------------------------------- const queryClient = new QueryClient(); @@ -64,6 +94,10 @@ export default async function PostsPage() { initialPageParam: undefined, }); + // --------------------------------------------------------------------------- + // Actions + // --------------------------------------------------------------------------- + const initialData = await getPostsAction(); // --------------------------------------------------------------------------- diff --git a/app/[locale]/products/page.tsx b/app/[locale]/products/page.tsx index c97a9f50..0989292d 100644 --- a/app/[locale]/products/page.tsx +++ b/app/[locale]/products/page.tsx @@ -15,6 +15,7 @@ import { Products } from "@/sections/products"; import type { Metadata } from "next"; import { getTranslations, setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; // ----------------------------------------------------------------------------- // Metadata @@ -23,6 +24,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server"; export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- diff --git a/app/[locale]/social/page.tsx b/app/[locale]/social/page.tsx index 23a2acd7..41147745 100644 --- a/app/[locale]/social/page.tsx +++ b/app/[locale]/social/page.tsx @@ -15,6 +15,7 @@ import { Social } from "@/sections/social"; import type { Metadata } from "next"; import { getTranslations, setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; // ----------------------------------------------------------------------------- // Metadata @@ -23,6 +24,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server"; export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- diff --git a/app/[locale]/values/page.tsx b/app/[locale]/values/page.tsx index 39f762eb..69bd470f 100644 --- a/app/[locale]/values/page.tsx +++ b/app/[locale]/values/page.tsx @@ -14,6 +14,7 @@ import type { Metadata } from "next"; import { getTranslations, setRequestLocale } from "next-intl/server"; +import { connection } from "next/server"; import SlugPage from "../[slug]/page"; // ----------------------------------------------------------------------------- @@ -33,6 +34,12 @@ const valuesSlugs = { export async function generateMetadata({ params, }: { params: Promise<{ locale: string }> }): Promise { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + // --------------------------------------------------------------------------- // i18n // --------------------------------------------------------------------------- diff --git a/app/error.tsx b/app/error.tsx index 6c29b906..c89cbe11 100644 --- a/app/error.tsx +++ b/app/error.tsx @@ -12,47 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -"use client"; // Error components must be Client Components - -import { useEffect } from "react"; +"use client"; // ----------------------------------------------------------------------------- // Page // ----------------------------------------------------------------------------- -// biome-ignore lint/suspicious/noShadowRestrictedNames: // biome-ignore lint/style/noDefaultExport: -export default function Error({ - error, - reset, -}: { - error: Error & { digest?: string }; - reset: () => void; -}) { - // --------------------------------------------------------------------------- - // Effect Hooks - // --------------------------------------------------------------------------- - - // biome-ignore lint/suspicious/noEmptyBlockStatements: - // biome-ignore lint/correctness/useExhaustiveDependencies: - useEffect(() => {}, [error]); - +// biome-ignore lint/suspicious/useAwait: +export default async function ErrorPage() { // --------------------------------------------------------------------------- // Render // --------------------------------------------------------------------------- - return ( -
-

Something went wrong!

- {/* biome-ignore lint/a11y/useButtonType: */} - -
- ); + return null; } diff --git a/app/layout.tsx b/app/layout.tsx index 587ce3b6..391d02bc 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -22,6 +22,7 @@ import { cn } from "@/lib/utils"; import type { Viewport } from "next"; import { getTranslations } from "next-intl/server"; import Script from "next/script"; +import { connection } from "next/server"; import type { ReactNode } from "react"; import "@lightdotso/styles/global.css"; @@ -45,8 +46,22 @@ export const viewport: Viewport = { }; export async function generateMetadata() { + // --------------------------------------------------------------------------- + // Server + // --------------------------------------------------------------------------- + + await connection(); + + // --------------------------------------------------------------------------- + // i18n + // --------------------------------------------------------------------------- + const t = await getTranslations({ locale: "en" }); + // --------------------------------------------------------------------------- + // Return + // --------------------------------------------------------------------------- + return { title: { default: t("site.title"), @@ -104,33 +119,28 @@ export default function RootLayout({ children }: RootLayoutProps) { // --------------------------------------------------------------------------- return ( - <> - - + +