refactor(blog): drive blog and home sections from markdown data
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { BlogDetailContent } from "@/components/blog-detail-content";
|
||||
import { getBlogDetailBySlug } from "@/data/blog-detail";
|
||||
import { getBlogEngagementBySlug } from "@/data/blog-engagement";
|
||||
|
||||
type BlogDetailPageProps = {
|
||||
params: Promise<{ slug: string }>;
|
||||
@@ -9,12 +8,11 @@ type BlogDetailPageProps = {
|
||||
|
||||
export default async function BlogDetailPage({ params }: BlogDetailPageProps) {
|
||||
const { slug } = await params;
|
||||
const post = getBlogDetailBySlug(slug);
|
||||
const engagement = getBlogEngagementBySlug(slug);
|
||||
const post = await getBlogDetailBySlug(slug);
|
||||
|
||||
if (!post) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return <BlogDetailContent post={post} engagement={engagement} />;
|
||||
return <BlogDetailContent post={post} />;
|
||||
}
|
||||
|
||||
+12
-2
@@ -1,5 +1,15 @@
|
||||
import { BlogContent } from "@/components/blog-content";
|
||||
import { getBlogPageData } from "@/data/blog";
|
||||
|
||||
export default function BlogPage() {
|
||||
return <BlogContent />;
|
||||
type BlogPageProps = {
|
||||
searchParams?: Promise<{ page?: string }>;
|
||||
};
|
||||
|
||||
export default async function BlogPage({ searchParams }: BlogPageProps) {
|
||||
const resolved = searchParams ? await searchParams : undefined;
|
||||
const page = Number(resolved?.page ?? "1");
|
||||
const currentPage = Number.isFinite(page) && page > 0 ? Math.floor(page) : 1;
|
||||
const data = await getBlogPageData(currentPage, 12);
|
||||
|
||||
return <BlogContent data={data} />;
|
||||
}
|
||||
|
||||
+5
-2
@@ -1,11 +1,14 @@
|
||||
import { HomeHero } from "@/components/home-hero";
|
||||
import { HomeVideosSection } from "@/components/home-videos-section";
|
||||
import { ReferencesSection } from "@/components/references-section";
|
||||
import { getHomeBlogNews } from "@/data/blog";
|
||||
|
||||
export default async function Home() {
|
||||
const homeNews = await getHomeBlogNews(3);
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<section className="flex h-full flex-col gap-4 overflow-hidden">
|
||||
<HomeHero />
|
||||
<HomeHero news={homeNews} />
|
||||
<ReferencesSection />
|
||||
<HomeVideosSection />
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user