Skip to content

Commit 97b8dd2

Browse files
committed
fix: include pageUrlOverrides in getStaticPaths for production builds
URL override paths (e.g., /articles, /notes) may not be in the sitemap if they're not directly linked from the root Notion page. This ensures they are pre-rendered at build time, fixing 404s in production.
1 parent 68af398 commit 97b8dd2

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

pages/[pageId].tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type GetStaticProps } from 'next'
22

33
import { NotionPage } from '@/components/NotionPage'
4-
import { domain, isDev } from '@/lib/config'
4+
import { domain, isDev, pageUrlOverrides } from '@/lib/config'
55
import { getSiteMap } from '@/lib/get-site-map'
66
import { resolveNotionPage } from '@/lib/resolve-notion-page'
77
import { type PageProps, type Params } from '@/lib/types'
@@ -34,13 +34,17 @@ export async function getStaticPaths() {
3434

3535
const siteMap = await getSiteMap()
3636

37+
// Combine sitemap paths with URL overrides (e.g., /articles, /notes)
38+
// URL overrides might not be in the sitemap if not directly linked from root
39+
const allPageIds = [
40+
...new Set([
41+
...Object.keys(siteMap.canonicalPageMap),
42+
...Object.keys(pageUrlOverrides)
43+
])
44+
]
45+
3746
const staticPaths = {
38-
paths: Object.keys(siteMap.canonicalPageMap).map((pageId) => ({
39-
params: {
40-
pageId
41-
}
42-
})),
43-
// paths: [],
47+
paths: allPageIds.map((pageId) => ({ params: { pageId } })),
4448
fallback: true
4549
}
4650

0 commit comments

Comments
 (0)