@@ -2,7 +2,7 @@ import { MDXRemoteSerializeResult } from 'next-mdx-remote'
22import { serialize } from 'next-mdx-remote/serialize'
33
44import { Layout } from '~/components/Layout'
5- import { GetStaticProps } from 'next'
5+ import { GetServerSideProps } from 'next'
66import { LetterTypingText } from '~/components/LetterTypingText'
77import { getRemoteBlogPost , getRemoteBlogPosts } from '~/sections/blog/remote-utils'
88import { Post } from '~/sections/blog/types'
@@ -26,8 +26,6 @@ type Params = {
2626 slug : string
2727}
2828
29- export const revalidate = 3600
30-
3129export default function PostPage ( { serializedPost, data, morePosts } : Props ) {
3230 const router = useRouter ( )
3331
@@ -71,21 +69,7 @@ export default function PostPage({ serializedPost, data, morePosts }: Props) {
7169 )
7270}
7371
74- export const getStaticPaths = async ( ) => {
75- // Get all published posts for static generation
76- const posts = await getRemoteBlogPosts ( )
77-
78- const paths = posts . map ( ( post ) => ( {
79- params : { slug : post . slug }
80- } ) )
81-
82- return {
83- paths,
84- fallback : 'blocking' // Enable ISR for new posts
85- }
86- }
87-
88- export const getStaticProps : GetStaticProps < Props , Params > = async ( { params } ) => {
72+ export const getServerSideProps : GetServerSideProps < Props > = async ( { params } ) => {
8973 if ( ! params ?. slug ) {
9074 return {
9175 notFound : true
@@ -94,7 +78,10 @@ export const getStaticProps: GetStaticProps<Props, Params> = async ({ params })
9478
9579 try {
9680 // Fetch post and all posts in parallel
97- const [ post , allPosts ] = await Promise . all ( [ getRemoteBlogPost ( params . slug ) , getRemoteBlogPosts ( ) ] )
81+ const [ post , allPosts ] = await Promise . all ( [
82+ getRemoteBlogPost ( params . slug as string ) ,
83+ getRemoteBlogPosts ( )
84+ ] )
9885
9986 if ( ! post ?. __id ) {
10087 return {
@@ -118,11 +105,10 @@ export const getStaticProps: GetStaticProps<Props, Params> = async ({ params })
118105 serializedPost,
119106 data : post ,
120107 morePosts
121- } ,
122- revalidate : 3600 // Revalidate every hour
108+ }
123109 }
124110 } catch ( error ) {
125- console . error ( 'Error in getStaticProps :' , error )
111+ console . error ( 'Error in getServerSideProps :' , error )
126112 return {
127113 notFound : true
128114 }
0 commit comments