Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ jobs:
node-version:
- 20
- 22
- 24

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
cache: "pnpm"

- run: pnpm install --frozen-lockfile --strict-peer-dependencies
- run: pnpm test
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist/
node_modules/
.next/
.vercel/
next-env.d.ts
11 changes: 8 additions & 3 deletions components/NotionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import Image from 'next/legacy/image'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { type PageBlock } from 'notion-types'
import { formatDate, getBlockTitle, getPageProperty } from 'notion-utils'
import {
formatDate,
getBlockTitle,
getBlockValue,
getPageProperty
} from 'notion-utils'
import * as React from 'react'
import BodyClassName from 'react-body-classname'
import {
Expand Down Expand Up @@ -224,7 +229,7 @@ export function NotionPage({
}, [site, recordMap, lite])

const keys = Object.keys(recordMap?.block || {})
const block = recordMap?.block?.[keys[0]!]?.value
const block = getBlockValue(recordMap?.block?.[keys[0]!])

// const isRootPage =
// parsePageId(block?.id) === parsePageId(site?.rootNotionPageId)
Expand All @@ -251,7 +256,7 @@ export function NotionPage({
return <Loading />
}

if (error || !site || !block) {
if (error || !site || !block || !recordMap) {
return <Page404 site={site} pageId={pageId} error={error} />
}

Expand Down
4 changes: 3 additions & 1 deletion lib/acl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getBlockValue } from 'notion-utils'

import { type PageProps } from './types'

export async function pageAcl({
Expand Down Expand Up @@ -35,7 +37,7 @@ export async function pageAcl({
}
}

const rootValue = recordMap.block[rootKey]?.value
const rootValue = getBlockValue(recordMap.block[rootKey])
const rootSpaceId = rootValue?.space_id

if (
Expand Down
9 changes: 7 additions & 2 deletions lib/get-site-map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { getAllPagesInSpace, getPageProperty, uuidToId } from 'notion-utils'
import {
getAllPagesInSpace,
getBlockValue,
getPageProperty,
uuidToId
} from 'notion-utils'
import pMemoize from 'p-memoize'

import type * as types from './types'
Expand Down Expand Up @@ -60,7 +65,7 @@ async function getAllPagesImpl(
throw new Error(`Error loading page "${pageId}"`)
}

const block = recordMap.block[pageId]?.value
const block = getBlockValue(recordMap.block[pageId])
if (
!(getPageProperty<boolean | null>('Public', block!, recordMap) ?? true)
) {
Expand Down
8 changes: 5 additions & 3 deletions lib/oembed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getPageTitle, parsePageId } from 'notion-utils'
import { getBlockValue, getPageTitle, parsePageId } from 'notion-utils'

import * as config from './config'
import { getPage } from './notion'
Expand Down Expand Up @@ -26,8 +26,10 @@ export const oembed = async ({
const pageTitle = getPageTitle(page)
if (pageTitle) title = pageTitle

const user = page.notion_user[Object.keys(page.notion_user)[0]!]!.value
const name = [user.given_name, user.family_name]
const user = getBlockValue(
page.notion_user[Object.keys(page.notion_user)[0]!]
)
const name = [user?.given_name, user?.family_name]
.filter(Boolean)
.join(' ')
.trim()
Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />
import "./.next/types/routes.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
39 changes: 16 additions & 23 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
// import path from 'node:path'
// import { fileURLToPath } from 'node:url'

import bundleAnalyzer from '@next/bundle-analyzer'

const withBundleAnalyzer = bundleAnalyzer({
// eslint-disable-next-line no-process-env
enabled: process.env.ANALYZE === 'true'
})

export default withBundleAnalyzer({
export default {
staticPageGenerationTimeout: 300,
images: {
remotePatterns: [
Expand All @@ -24,19 +17,19 @@ export default withBundleAnalyzer({
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;"
},

webpack: (config) => {
// Workaround for ensuring that `react` and `react-dom` resolve correctly
// when using a locally-linked version of `react-notion-x`.
// @see https://github.com/vercel/next.js/issues/50391
const dirname = path.dirname(fileURLToPath(import.meta.url))
config.resolve.alias.react = path.resolve(dirname, 'node_modules/react')
config.resolve.alias['react-dom'] = path.resolve(
dirname,
'node_modules/react-dom'
)
return config
},
// webpack: (config) => {
// // Workaround for ensuring that `react` and `react-dom` resolve correctly
// // when using a locally-linked version of `react-notion-x`.
// // @see https://github.com/vercel/next.js/issues/50391
// const dirname = path.dirname(fileURLToPath(import.meta.url))
// config.resolve.alias.react = path.resolve(dirname, 'node_modules/react')
// config.resolve.alias['react-dom'] = path.resolve(
// dirname,
// 'node_modules/react-dom'
// )
// return config
// },

// See https://react-tweet.vercel.app/next#troubleshooting
transpilePackages: ['react-tweet']
})
}
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,37 @@
"classnames": "^2.5.1",
"expiry-map": "^2.0.0",
"fathom-client": "^3.4.1",
"ky": "^1.8.1",
"katex": "^0.16.28",
"ky": "^1.14.3",
"lqip-modern": "^2.2.1",
"next": "^15.5.3",
"notion-client": "^7.7.0",
"notion-types": "^7.7.0",
"notion-utils": "^7.7.0",
"p-map": "^7.0.3",
"p-memoize": "^7.1.1",
"next": "^16.1.6",
"notion-client": "^7.8.1",
"notion-types": "^7.8.1",
"notion-utils": "^7.8.1",
"p-map": "^7.0.4",
"p-memoize": "^8.0.0",
"posthog-js": "^1.249.4",
"prismjs": "^1.30.0",
"react": "^19.1.1",
"react": "^19.2.4",
"react-body-classname": "^1.3.1",
"react-dom": "^19.1.1",
"react-notion-x": "^7.7.0",
"react-tweet": "^3.2.2",
"react-dom": "^19.2.4",
"react-notion-x": "^7.8.1",
"react-tweet": "^3.3.0",
"react-use": "^17.6.0",
"rss": "^1.2.2"
},
"devDependencies": {
"@fisch0920/config": "^1.2.1",
"@next/bundle-analyzer": "^15.3.3",
"@types/node": "^24.5.2",
"@fisch0920/config": "^1.4.0",
"@types/node": "^25.2.3",
"@types/prismjs": "^1.26.5",
"@types/react": "^19.1.13",
"@types/react": "^19.2.14",
"@types/react-body-classname": "^1.1.10",
"@types/rss": "^0.0.32",
"cross-env": "^10.0.0",
"eslint": "^9.35.0",
"cross-env": "^10.1.0",
"eslint": "^9.39.2",
"npm-run-all2": "^8.0.4",
"prettier": "^3.6.2",
"typescript": "^5.9.2"
"prettier": "^3.8.1",
"typescript": "^5.9.3"
},
"overrides": {
"cacheable-request": {
Expand Down
Loading