Skip to content

Commit 5654d75

Browse files
committed
feat: add ssg
1 parent 33091a0 commit 5654d75

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/posts/[slug]/page.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@ import {
33
getFeaturedMediaById,
44
getAuthorById,
55
getCategoryById,
6+
getAllPosts,
67
} from "@/lib/wordpress";
78

89
import { Section, Container, Article, Prose } from "@/components/craft";
9-
import { Metadata } from "next";
1010
import { badgeVariants } from "@/components/ui/badge";
1111
import { cn } from "@/lib/utils";
1212
import { siteConfig } from "@/site.config";
1313

1414
import Link from "next/link";
1515
import Balancer from "react-wrap-balancer";
1616

17+
import type { Metadata } from "next";
18+
19+
export async function generateStaticParams() {
20+
const posts = await getAllPosts();
21+
22+
return posts.map((post) => ({
23+
slug: post.slug,
24+
}));
25+
}
26+
1727
export async function generateMetadata({
1828
params,
1929
}: {
@@ -65,7 +75,9 @@ export default async function Page({
6575
}) {
6676
const { slug } = await params;
6777
const post = await getPostBySlug(slug);
68-
const featuredMedia = post.featured_media ? await getFeaturedMediaById(post.featured_media) : null;
78+
const featuredMedia = post.featured_media
79+
? await getFeaturedMediaById(post.featured_media)
80+
: null;
6981
const author = await getAuthorById(post.author);
7082
const date = new Date(post.date).toLocaleDateString("en-US", {
7183
month: "long",

0 commit comments

Comments
 (0)