Skip to content

Commit

Permalink
New file - copy of other
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeraze committed Nov 20, 2022
1 parent 90d5720 commit 138eb7c
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions pages/post/[pageId].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import * as React from 'react'
import { GetStaticProps } from 'next'

import { NotionPage } from '@/components/NotionPage'
import { domain, isDev } from '@/lib/config'
import { getSiteMap } from '@/lib/get-site-map'
import { resolveNotionPage } from '@/lib/resolve-notion-page'
import { PageProps, Params } from '@/lib/types'

export const getStaticProps: GetStaticProps<PageProps, Params> = async (
context
) => {
const rawPageId = context.params.pageId as string

try {
console.error(rawPageId)
const props = await resolveNotionPage(domain, rawPageId)

return { props, revalidate: 10 }
} catch (err) {
console.error('page error', domain, rawPageId, err)

// we don't want to publish the error version of this page, so
// let next.js know explicitly that incremental SSG failed
throw err
}
}

export async function getStaticPaths() {
if (isDev) {
return {
paths: [],
fallback: true
}
}

const siteMap = await getSiteMap()

const staticPaths = {
paths: Object.keys(siteMap.canonicalPageMap).map((pageId) => ({
params: {
pageId
}
})),
// paths: [],
fallback: true
}

console.log(staticPaths.paths)
return staticPaths
}

export default function NotionDomainDynamicPage(props) {
return <NotionPage {...props} />
}

0 comments on commit 138eb7c

Please sign in to comment.