Skip to content

Commit 5bbeb3e

Browse files
committed
Temporary disabled ISR
1 parent 48677ca commit 5bbeb3e

8 files changed

Lines changed: 83 additions & 160 deletions

File tree

website/next.config.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ const nextConfig = {
1010
env: {
1111
NEXT_PUBLIC_APP_VERSION: version
1212
},
13-
// Remove standalone output for Amplify - it uses its own serverless setup
14-
// output: 'standalone',
15-
16-
// Enable experimental ISR features for better Amplify compatibility
17-
experimental: {
18-
isrMemoryCacheSize: 0 // Disable in-memory cache for better ISR behavior on Amplify
19-
},
2013
// compiler: {
2114
// styledJsx: false
2215
// },

website/src/pages/[slug].tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { MDXRemoteSerializeResult } from 'next-mdx-remote'
22

33
import { Layout } from '~/components/Layout'
4-
import { GetStaticProps, GetStaticPaths } from 'next'
4+
import { GetServerSideProps } from 'next'
55
import { Page } from '~/sections/blog/types'
66
import { MDXPageRenderer } from '~/sections/blog/MDXRenderer'
77
import { getRemotePage } from '~/sections/blog/remote-utils'
@@ -17,8 +17,6 @@ type Params = {
1717
slug: string
1818
}
1919

20-
export const revalidate = 3600
21-
2220
export default function StaticPage({ serializedPage, data }: Props) {
2321
return (
2422
<Layout title={data.title}>
@@ -27,23 +25,14 @@ export default function StaticPage({ serializedPage, data }: Props) {
2725
)
2826
}
2927

30-
export const getStaticPaths: GetStaticPaths = async () => {
31-
// For static pages, we'll use fallback: 'blocking' to generate pages on-demand
32-
// This allows for ISR with new pages that weren't pre-built
33-
return {
34-
paths: [], // We'll generate pages on-demand
35-
fallback: 'blocking'
36-
}
37-
}
38-
39-
export const getStaticProps: GetStaticProps<Props, Params> = async ({ params }) => {
28+
export const getServerSideProps: GetServerSideProps<Props> = async ({ params }) => {
4029
if (!params?.slug) {
4130
return {
4231
notFound: true
4332
}
4433
}
4534

46-
const page = await getRemotePage(params.slug)
35+
const page = await getRemotePage(params.slug as string)
4736

4837
if (!page?.__id) {
4938
return {
@@ -62,7 +51,6 @@ export const getStaticProps: GetStaticProps<Props, Params> = async ({ params })
6251
props: {
6352
serializedPage,
6453
data: page
65-
},
66-
revalidate: 3600 // Revalidate every hour
54+
}
6755
}
6856
}

website/src/pages/api/revalidate.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
1515
} else if (type === 'page' && slug) {
1616
// Revalidate the specific page
1717
await res.revalidate(`/${slug}`)
18-
} else if (type === 'pricing') {
19-
// Revalidate the pricing page
20-
await res.revalidate('/pricing')
21-
} else if (type === 'homepage') {
22-
// Revalidate the homepage
23-
await res.revalidate('/')
2418
}
2519

2620
// Revalidate blog index regardless of type
@@ -32,8 +26,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
3226
paths:
3327
type === 'post' && slug ? [`/blog/${slug}`, '/blog']
3428
: type === 'page' && slug ? [`/${slug}`]
35-
: type === 'pricing' ? ['/pricing']
36-
: type === 'homepage' ? ['/']
3729
: ['/blog']
3830
})
3931
} catch (err) {

website/src/pages/blog/[slug].tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MDXRemoteSerializeResult } from 'next-mdx-remote'
22
import { serialize } from 'next-mdx-remote/serialize'
33

44
import { Layout } from '~/components/Layout'
5-
import { GetStaticProps } from 'next'
5+
import { GetServerSideProps } from 'next'
66
import { LetterTypingText } from '~/components/LetterTypingText'
77
import { getRemoteBlogPost, getRemoteBlogPosts } from '~/sections/blog/remote-utils'
88
import { Post } from '~/sections/blog/types'
@@ -26,8 +26,6 @@ type Params = {
2626
slug: string
2727
}
2828

29-
export const revalidate = 3600
30-
3129
export 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
}

website/src/pages/blog/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from 'classnames'
2-
import { GetStaticProps } from 'next'
2+
import { GetServerSideProps } from 'next'
33

44
import { Layout } from '~/components/Layout'
55
import { LetterTypingText } from '~/components/LetterTypingText'
@@ -9,8 +9,6 @@ import { getRemoteBlogPosts } from '~/sections/blog/remote-utils'
99

1010
type Props = { posts: Array<Post['data']> }
1111

12-
export const revalidate = 3600
13-
1412
export default function Index({ posts }: Props) {
1513
return (
1614
<Layout className="container">
@@ -43,13 +41,12 @@ export default function Index({ posts }: Props) {
4341
)
4442
}
4543

46-
export const getStaticProps: GetStaticProps<Props> = async () => {
44+
export const getServerSideProps: GetServerSideProps<Props> = async () => {
4745
const posts = await getRemoteBlogPosts()
4846

4947
return {
5048
props: {
5149
posts
52-
},
53-
revalidate: 3600 // Revalidate every hour (3600 seconds)
50+
}
5451
}
5552
}

website/src/pages/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GetStaticProps } from 'next'
1+
import { GetServerSideProps } from 'next'
22
import { Layout } from '~/components/Layout'
33
import { Hero } from '~/sections/Hero'
44
import { SocialProof } from '~/sections/SocialProof'
@@ -29,13 +29,12 @@ export default function Home({ featuredPosts }: Props) {
2929
)
3030
}
3131

32-
export const getStaticProps: GetStaticProps<Props> = async () => {
32+
export const getServerSideProps: GetServerSideProps<Props> = async () => {
3333
const featuredPosts = await getFeaturedBlogPosts(3)
3434

3535
return {
3636
props: {
3737
featuredPosts
38-
},
39-
revalidate: 3600 // Revalidate every hour
38+
}
4039
}
4140
}

website/src/pages/pricing.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Layout } from '~/components/Layout'
22
import { Pricing } from '~/sections/Pricing'
3-
import { GetStaticProps } from 'next'
3+
import { GetServerSideProps } from 'next'
44

55
type PaidStartPlanId = 'start'
66
type PaidPlanId = 'pro'
@@ -29,16 +29,15 @@ export default function PricingPage({ billingData }: PricingPageProps) {
2929
)
3030
}
3131

32-
export const getStaticProps: GetStaticProps<PricingPageProps> = async () => {
32+
export const getServerSideProps: GetServerSideProps<PricingPageProps> = async () => {
3333
try {
3434
const res = await fetch('https://billing.rushdb.com/api/prices')
3535

3636
if (!res.ok) {
3737
return {
3838
props: {
3939
billingData: null
40-
},
41-
revalidate: 300 // Revalidate every 5 minutes on error
40+
}
4241
}
4342
}
4443

@@ -47,16 +46,14 @@ export const getStaticProps: GetStaticProps<PricingPageProps> = async () => {
4746
return {
4847
props: {
4948
billingData
50-
},
51-
revalidate: 3600 // Revalidate every hour
49+
}
5250
}
5351
} catch (error) {
5452
console.error('Failed to fetch billing data:', error)
5553
return {
5654
props: {
5755
billingData: null
58-
},
59-
revalidate: 300 // Revalidate every 5 minutes on error
56+
}
6057
}
6158
}
6259
}

0 commit comments

Comments
 (0)