Skip to content

Commit dad75a1

Browse files
Updated to fix 404 blog not found error
1 parent fecf779 commit dad75a1

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

app/blog/[slug]/page.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { getPostData, getSortedPostsData } from '@/lib/posts'
22

33
export async function generateStaticParams() {
4-
const posts = getSortedPostsData()
5-
return posts.map(post => ({ slug: post.slug }))
6-
}
4+
const posts = getSortedPostsData();
5+
return posts.map(post => ({
6+
slug: post.slug,
7+
}));
8+
}
9+
710

811
export default async function Post({ params }: { params: { slug: string } }) {
912
const postData = await getPostData(params.slug)

app/blog/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function BlogPage() {
1010
<div className="space-y-4">
1111
{allPostsData.map(({ slug, date, title }) => (
1212
<article key={slug} className="border-b pb-4">
13-
<Link href={`/blog/${slug}`} className="text-xl font-semibold hover:text-blue-600">
13+
<Link href={`/blog/${slug}/`} className="text-xl font-semibold hover:text-blue-600">
1414
{title}
1515
</Link>
1616
<p className="text-sm text-gray-500 mt-1">{new Date(date).toLocaleDateString()}</p>

next.config.mjs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
/**
2-
* @type {import('next').NextConfig}
3-
*/
1+
/** @type {import('next').NextConfig} */
42
const nextConfig = {
5-
output: "export",
6-
images: {
7-
loader: "akamai",
8-
path: "",
9-
},
10-
assetPrefix: "/",
11-
};
12-
13-
export default nextConfig;
3+
output: 'export',
4+
trailingSlash: true,
5+
images: {
6+
unoptimized: true,
7+
},
8+
// Remove the exportPathMap entirely or use this alternative:
9+
async exportPathMap() {
10+
return {
11+
'/': { page: '/' },
12+
'/blog': { page: '/blog' },
13+
// Blog posts will be automatically generated by generateStaticParams
14+
}
15+
}
16+
}
17+
18+
export default nextConfig

0 commit comments

Comments
 (0)