Skip to content

Commit 1b55c48

Browse files
committed
アニメーション機能を実装。
1 parent 50d0583 commit 1b55c48

File tree

4 files changed

+32
-30
lines changed

4 files changed

+32
-30
lines changed

src/app/[article_year]/[month]/[aid]/page.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { getArticleIndexes } from "@/app/article/article";
33
import { toHTML } from "@/app/article/article";
44
import "./page.css";
55
import { Metadata } from "next";
6+
import Loading from "@/app/loading";
7+
import { Suspense } from "react";
68
export async function generateStaticParams() {
79
const indexes = getArticleIndexes();
810

@@ -46,7 +48,7 @@ export async function generateMetadata({
4648
const og_image_url = `${slug}/${article?.thumbnail?.split("/").slice(-1)[0]}`;
4749
const metadata: Metadata = {
4850
metadataBase: new URL(
49-
process.env.BASE_URL || "https://the-infinitys.f5.si",
51+
process.env.BASE_URL || "https://the-infinitys.f5.si"
5052
),
5153
title: fullTitle, // ページのタイトルを設定
5254
description: description, // ページのディスクリプションを設定
@@ -72,5 +74,9 @@ export default function ArticlePage({
7274
}: {
7375
params: Promise<{ article_year: string; month: string; aid: string }>;
7476
}) {
75-
return <ArticleServer params={params} />;
77+
return (
78+
<Suspense fallback={<Loading />}>
79+
<ArticleServer params={params} />
80+
</Suspense>
81+
);
7682
}

src/app/article/page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import "./page.css";
33
import Explains from "./components/explains";
44
import ArticlePage from "./components/articlepage"; // クライアントコンポーネントをインポート
55
import { Metadata } from "next";
6-
6+
import Loading from "@/app/loading";
7+
import { Suspense } from "react";
78
export const metadata: Metadata = {
89
title: "The Infinity's Articles",
910
description: "Much! A lot of! Ideas!",
@@ -13,7 +14,9 @@ export default function Article() {
1314
return (
1415
<>
1516
<Explains />
16-
<ArticlePage />
17+
<Suspense fallback={<Loading />}>
18+
<ArticlePage />
19+
</Suspense>
1720
</>
1821
);
1922
}

src/app/layout.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import "./globals.css";
22
import Header from "./layout/header";
33
import Footer from "./layout/footer";
4-
import { Suspense } from "react";
54
import BackToTopButton from "./layout/back2top";
65
import I18nProvider from "./i18nProvider";
76
import { Geist, Geist_Mono } from "next/font/google";
87
import type { Metadata } from "next";
9-
import Loading from "./loading";
108
export const metadata: Metadata = {
119
title: "The Infinity's",
1210
description: "Believe in The Infinite Possibilities!",
@@ -32,11 +30,9 @@ export default async function RootLayout({
3230
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
3331
>
3432
<I18nProvider>
35-
<Suspense fallback={<Loading />}>
36-
<Header />
37-
{children}
38-
<Footer />
39-
</Suspense>
33+
<Header />
34+
{children}
35+
<Footer />
4036
</I18nProvider>
4137
<BackToTopButton />
4238
</body>

src/app/template.tsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
"use client";
22
import { motion } from "framer-motion";
33
import React from "react";
4-
import { AnimatePresence } from "framer-motion";
5-
64
const variants = {
75
hidden: { opacity: 0 },
86
enter: { opacity: 1 },
97
};
108

119
export default function Template({ children }: { children: React.ReactNode }) {
1210
return (
13-
<AnimatePresence exitBeforeEnter>
14-
<motion.main
15-
className="site-wrapper"
16-
variants={variants}
17-
initial="hidden"
18-
animate="enter"
19-
style={{
20-
minHeight: "100vh",
21-
}}
22-
transition={{
23-
type: "linear",
24-
duration: 2,
25-
}}
26-
>
27-
{children}
28-
</motion.main>
29-
</AnimatePresence>
11+
<motion.main
12+
className="site-wrapper"
13+
variants={variants}
14+
initial={{ opacity: 0 }}
15+
animate={{ opacity: 1 }}
16+
// exit={{ opacity: 0 }} // no means
17+
style={{
18+
minHeight: "100vh",
19+
}}
20+
transition={{
21+
type: "linear",
22+
duration: 2,
23+
}}
24+
>
25+
{children}
26+
</motion.main>
3027
);
3128
}

0 commit comments

Comments
 (0)