Skip to content

Commit d276528

Browse files
committed
💥 Add motion to blog pages for testing
1 parent 0f470d5 commit d276528

5 files changed

Lines changed: 102 additions & 18 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"clsx": "^2.1.1",
2222
"gray-matter": "^4.0.3",
2323
"lucide-react": "^0.523.0",
24+
"motion": "^12.23.12",
2425
"next": "15.3.4",
2526
"next-mdx-remote": "^5.0.0",
2627
"next-themes": "^0.4.6",

pnpm-lock.yaml

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/blog/posts/[slug]/page.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getMDXComponents } from "@/mdx-components";
99
import { posts } from "@/utils/posts";
1010
import rehypeSlug from "rehype-slug";
1111
import BlogPostTracker from "@/components/blog-post-tracker";
12+
import Transition from "@/components/ui/transition";
1213

1314
type PageProps = {
1415
params: Promise<{
@@ -34,24 +35,26 @@ export default async function Page({ params }: {
3435
return (
3536
<main className="md:max-w-3xl w-full px-8 m-auto">
3637
<BlogPostTracker postId={idx}/>
37-
<h1
38-
className={`${post.title.length <= 20 ? "text-4xl" : "text-3xl"} font-bold text-foreground`}
39-
>
40-
{post.title}
41-
</h1>
42-
<h2 className="text-xl mb-2 text-foreground/60">
43-
{post.date}{post.author}
44-
</h2>
45-
<MDXRemote
46-
source={post.content}
47-
components={components}
48-
options={{
49-
mdxOptions: {
50-
remarkPlugins: [remarkGfm],
51-
rehypePlugins: [rehypeUnwrapImages, rehypeSlug],
52-
},
53-
}}
54-
/>
38+
<Transition>
39+
<h1
40+
className={`${post.title.length <= 20 ? "text-4xl" : "text-3xl"} font-bold text-foreground`}
41+
>
42+
{post.title}
43+
</h1>
44+
<h2 className="text-xl mb-2 text-foreground/60">
45+
{post.date}{post.author}
46+
</h2>
47+
<MDXRemote
48+
source={post.content}
49+
components={components}
50+
options={{
51+
mdxOptions: {
52+
remarkPlugins: [remarkGfm],
53+
rehypePlugins: [rehypeUnwrapImages, rehypeSlug],
54+
},
55+
}}
56+
/>
57+
</Transition>
5558
{(prev || next) && (
5659
<BlogFooter prevSlug={prev?.slug} nextSlug={next?.slug} />
5760
)}

src/app/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import AchievementsProvider from "@/components/achievements-provider";
99
import { posts } from "@/utils/posts";
1010
import { ToasterProvider } from "@/components/toaster-provider";
1111
import ShopProvider from "@/components/shop-provider";
12+
import Transition from "@/components/ui/transition";
1213

1314
const karlaSans = Karla({
1415
variable: "--font-karla",

src/components/ui/transition.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use client';
2+
3+
import { motion } from 'motion/react';
4+
5+
export default function Transition({
6+
children
7+
}: {
8+
children: React.ReactNode
9+
}) {
10+
return (
11+
<motion.div
12+
initial={{y: 20, opacity: 0}}
13+
animate={{y: 0, opacity: 1}}
14+
transition={{ease: 'easeInOut', duration: 0.75}}
15+
>
16+
{children}
17+
</motion.div>
18+
)
19+
}

0 commit comments

Comments
 (0)