Skip to content

Commit

Permalink
Merge pull request #422 from shunkakinoki/fix/ini-site-dynamic
Browse files Browse the repository at this point in the history
fix: ini site dynamic
  • Loading branch information
shunkakinoki authored Oct 28, 2024
2 parents db6f6f1 + b9169df commit 5605138
Show file tree
Hide file tree
Showing 37 changed files with 1,482 additions and 1,092 deletions.
56 changes: 52 additions & 4 deletions app/[locale]/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

// -----------------------------------------------------------------------------
Expand All @@ -34,8 +35,22 @@ import { Suspense } from "react";
export async function generateMetadata({
params,
}: { params: Promise<{ slug: string }> }): Promise<Metadata> {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// Services
// ---------------------------------------------------------------------------

const page = await getCachedPage((await params).slug);

// ---------------------------------------------------------------------------
// Return
// ---------------------------------------------------------------------------

return {
//@ts-ignore
title: page.properties?.Name?.title[0]?.plain_text,
Expand All @@ -49,20 +64,53 @@ export async function generateMetadata({
// -----------------------------------------------------------------------------

// biome-ignore lint/style/noDefaultExport: <explanation>
// biome-ignore lint/suspicious/useAwait: <explanation>
export default async function SlugPage({
params,
}: { params: Promise<{ locale: string; slug: string }> }) {
// ---------------------------------------------------------------------------
// Services
// Render
// ---------------------------------------------------------------------------

return (
<Suspense fallback={null}>
<SlugInnerPage params={params} />
</Suspense>
);
}

// -----------------------------------------------------------------------------
// 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);

Expand Down Expand Up @@ -148,13 +196,13 @@ export default async function SlugPage({
page.parent.database_id ===
"badf29d8-7d2f-4e03-b2c5-451a627d8618" && (
<div className="flex flex-col gap-4 md:gap-8">
<Suspense>
<Suspense fallback={null}>
<Check
// @ts-ignore
dateStart={page.properties.Date.date.start}
/>
</Suspense>
<Suspense>
<Suspense fallback={null}>
<Mind
// @ts-ignore
dateStart={page.properties.Date.date.start}
Expand Down
11 changes: 9 additions & 2 deletions app/[locale]/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import { Life } from "@/sections/life";
import type { Metadata } from "next";
import { getTranslations, setRequestLocale } from "next-intl/server";
import { connection } from "next/server";
import SlugPage from "../[slug]/page";

// -----------------------------------------------------------------------------
Expand All @@ -34,6 +35,12 @@ const aboutSlugs = {
export async function generateMetadata({
params,
}: { params: Promise<{ locale: string }> }): Promise<Metadata> {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// i18n
// ---------------------------------------------------------------------------
Expand All @@ -51,12 +58,12 @@ export async function generateMetadata({
}

// -----------------------------------------------------------------------------
// Page
// Page
// -----------------------------------------------------------------------------

// biome-ignore lint/style/noDefaultExport: <explanation>
// biome-ignore lint/suspicious/useAwait: <explanation>
export default async function AboutPage({
export default async function AboutInnerPage({
params,
}: { params: Promise<{ locale: string }> }) {
// ---------------------------------------------------------------------------
Expand Down
38 changes: 37 additions & 1 deletion app/[locale]/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +31,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server";
export async function generateMetadata({
params,
}: { params: Promise<{ locale: string }> }): Promise<Metadata> {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// i18n
// ---------------------------------------------------------------------------
Expand All @@ -54,14 +62,38 @@ export async function generateMetadata({
export default async function BlogPage({
params,
}: { params: Promise<{ locale: string }> }) {
// ---------------------------------------------------------------------------
// Render
// ---------------------------------------------------------------------------

return (
<Suspense fallback={null}>
<BlogInnerPage params={params} />
</Suspense>
);
}

// -----------------------------------------------------------------------------
// Inner Page
// -----------------------------------------------------------------------------

async function BlogInnerPage({
params,
}: { params: Promise<{ locale: string }> }) {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// i18n
// ---------------------------------------------------------------------------

setRequestLocale((await params).locale);

// ---------------------------------------------------------------------------
// Actions
// Query
// ---------------------------------------------------------------------------

const queryClient = new QueryClient();
Expand All @@ -73,6 +105,10 @@ export default async function BlogPage({
initialPageParam: undefined,
});

// ---------------------------------------------------------------------------
// Actions
// ---------------------------------------------------------------------------

const initialData = await getBlogAction((await params).locale);

// ---------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions app/[locale]/cause/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

// -----------------------------------------------------------------------------
Expand All @@ -33,6 +34,12 @@ const causeSlugs = {
export async function generateMetadata({
params,
}: { params: Promise<{ locale: string }> }): Promise<Metadata> {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// i18n
// ---------------------------------------------------------------------------
Expand Down
14 changes: 13 additions & 1 deletion app/[locale]/clock/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +25,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server";
export async function generateMetadata({
params,
}: { params: Promise<{ locale: string }> }): Promise<Metadata> {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// i18n
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -57,5 +65,9 @@ export default async function ClockPage({
// Render
// ---------------------------------------------------------------------------

return <Clock />;
return (
<Suspense fallback={null}>
<Clock />
</Suspense>
);
}
7 changes: 7 additions & 0 deletions app/[locale]/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +24,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server";
export async function generateMetadata({
params,
}: { params: Promise<{ locale: string }> }): Promise<Metadata> {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// i18n
// ---------------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions app/[locale]/[...rest]/page.tsx → app/[locale]/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: <explanation>
export default function CatchAllPage() {
// biome-ignore lint/suspicious/useAwait: <explanation>
export default async function ErrorPage() {
// ---------------------------------------------------------------------------
// Render
// ---------------------------------------------------------------------------

notFound();
return null;
}
7 changes: 7 additions & 0 deletions app/[locale]/history/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +24,12 @@ import { getTranslations, setRequestLocale } from "next-intl/server";
export async function generateMetadata({
params,
}: { params: Promise<{ locale: string }> }): Promise<Metadata> {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// i18n
// ---------------------------------------------------------------------------
Expand Down
36 changes: 35 additions & 1 deletion app/[locale]/journal/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +31,12 @@ import { getTranslations } from "next-intl/server";
export async function generateMetadata({
params,
}: { params: Promise<{ locale: string }> }): Promise<Metadata> {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// i18n
// ---------------------------------------------------------------------------
Expand All @@ -53,7 +61,29 @@ export async function generateMetadata({
// biome-ignore lint/suspicious/useAwait: <explanation>
export default async function JournalPage() {
// ---------------------------------------------------------------------------
// Actions
// Render
// ---------------------------------------------------------------------------

return (
<Suspense fallback={null}>
<JournalInnerPage />
</Suspense>
);
}

// -----------------------------------------------------------------------------
// Inner Page
// -----------------------------------------------------------------------------

async function JournalInnerPage() {
// ---------------------------------------------------------------------------
// Server
// ---------------------------------------------------------------------------

await connection();

// ---------------------------------------------------------------------------
// Query
// ---------------------------------------------------------------------------

const queryClient = new QueryClient();
Expand All @@ -64,6 +94,10 @@ export default async function JournalPage() {
initialPageParam: undefined,
});

// ---------------------------------------------------------------------------
// Actions
// ---------------------------------------------------------------------------

const initialData = await getJournalAction();

// ---------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 5605138

Please sign in to comment.