Skip to content

Commit 0eadf00

Browse files
feat: update react-notion-x
1 parent 484c14a commit 0eadf00

9 files changed

Lines changed: 436 additions & 167 deletions

File tree

components/NotionPage.tsx

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import styles from './styles.module.css'
4141
// -----------------------------------------------------------------------------
4242

4343
const Code = dynamic(() =>
44-
import('react-notion-x/build/third-party/code').then(async (m) => {
44+
import('react-notion-x/third-party/code').then(async (m) => {
4545
// add / remove any prism syntaxes here
4646
await Promise.allSettled([
4747
// @ts-expect-error Ignore prisma types
@@ -112,22 +112,20 @@ const Code = dynamic(() =>
112112
)
113113

114114
const Collection = dynamic(() =>
115-
import('react-notion-x/build/third-party/collection').then(
116-
(m) => m.Collection
117-
)
115+
import('react-notion-x/third-party/collection').then((m) => m.Collection)
118116
)
119117
const Equation = dynamic(() =>
120-
import('react-notion-x/build/third-party/equation').then((m) => m.Equation)
118+
import('react-notion-x/third-party/equation').then((m) => m.Equation)
121119
)
122120
const Pdf = dynamic(
123-
() => import('react-notion-x/build/third-party/pdf').then((m) => m.Pdf),
121+
() => import('react-notion-x/third-party/pdf').then((m) => m.Pdf),
124122
{
125123
ssr: false
126124
}
127125
)
128126
const Modal = dynamic(
129127
() =>
130-
import('react-notion-x/build/third-party/modal').then((m) => {
128+
import('react-notion-x/third-party/modal').then((m) => {
131129
m.Modal.setAppElement('.notion-viewport')
132130
return m.Modal
133131
}),
@@ -188,6 +186,21 @@ const propertyTextValue = (
188186
return defaultFn()
189187
}
190188

189+
const notionRendererComponents: Partial<NotionComponents> = {
190+
nextLegacyImage: Image,
191+
nextLink: Link,
192+
Code,
193+
Collection,
194+
Equation,
195+
Pdf,
196+
Modal,
197+
Tweet,
198+
Header: NotionPageHeader,
199+
propertyLastEditedTimeValue,
200+
propertyTextValue,
201+
propertyDateValue
202+
}
203+
191204
export function NotionPage({
192205
site,
193206
recordMap,
@@ -197,24 +210,6 @@ export function NotionPage({
197210
const router = useRouter()
198211
const lite = useSearchParam('lite')
199212

200-
const components = React.useMemo<Partial<NotionComponents>>(
201-
() => ({
202-
nextLegacyImage: Image,
203-
nextLink: Link,
204-
Code,
205-
Collection,
206-
Equation,
207-
Pdf,
208-
Modal,
209-
Tweet,
210-
Header: NotionPageHeader,
211-
propertyLastEditedTimeValue,
212-
propertyTextValue,
213-
propertyDateValue
214-
}),
215-
[]
216-
)
217-
218213
// lite mode is for oembed
219214
const isLiteMode = lite === 'true'
220215

@@ -250,8 +245,6 @@ export function NotionPage({
250245
[block, recordMap, isBlogPost]
251246
)
252247

253-
const footer = React.useMemo(() => <Footer />, [])
254-
255248
if (router.isFallback) {
256249
return <Loading />
257250
}
@@ -314,7 +307,7 @@ export function NotionPage({
314307
pageId === site.rootNotionPageId && 'index-page'
315308
)}
316309
darkMode={isDarkMode}
317-
components={components}
310+
components={notionRendererComponents}
318311
recordMap={recordMap}
319312
rootPageId={site.rootNotionPageId}
320313
rootDomain={site.domain}
@@ -330,7 +323,7 @@ export function NotionPage({
330323
mapImageUrl={mapImageUrl}
331324
searchNotion={config.isSearchEnabled ? searchNotion : undefined}
332325
pageAside={pageAside}
333-
footer={footer}
326+
footer={<Footer />}
334327
/>
335328

336329
<GitHubShareButton />

lib/acl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getBlockValue } from 'notion-utils'
22

3-
import { type PageProps } from './types'
3+
import type { PageProps } from './types'
44

55
export async function pageAcl({
66
site,

lib/get-tweets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { type ExtendedRecordMap } from 'notion-types'
22
import { getPageTweetIds } from 'notion-utils'
33
import pMap from 'p-map'
44
import pMemoize from 'p-memoize'
5-
import { getTweet as getTweetData } from 'react-tweet/api'
5+
import { getTweet as getTweetData, type Tweet } from 'react-tweet/api'
66

77
import type { ExtendedTweetRecordMap } from './types'
88
import { db } from './db'
@@ -27,7 +27,7 @@ export async function getTweetsMap(
2727
;(recordMap as ExtendedTweetRecordMap).tweets = tweetsMap
2828
}
2929

30-
async function getTweetImpl(tweetId: string): Promise<any> {
30+
async function getTweetImpl(tweetId: string): Promise<Tweet | null> {
3131
if (!tweetId) return null
3232

3333
const cacheKey = `tweet:${tweetId}`

lib/icons/moon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function MoonIcon() {
66
width='1em'
77
height='1em'
88
viewBox='0 0 512 512'
9-
stroke-width='0'
9+
strokeWidth='0'
1010
>
1111
<path d='M152.62 126.77c0-33 4.85-66.35 17.23-94.77C87.54 67.83 32 151.89 32 247.38 32 375.85 136.15 480 264.62 480c95.49 0 179.55-55.54 215.38-137.85-28.42 12.38-61.8 17.23-94.77 17.23-128.47 0-232.61-104.14-232.61-232.61z'></path>
1212
</svg>

lib/icons/sun.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ export function SunIcon() {
1010
>
1111
<path
1212
fill='none'
13-
stroke-linecap='round'
14-
stroke-miterlimit='10'
15-
stroke-width='32'
13+
strokeLinecap='round'
14+
strokeMiterlimit='10'
15+
strokeWidth='32'
1616
d='M256 48v48m0 320v48m147.08-355.08l-33.94 33.94M142.86 369.14l-33.94 33.94M464 256h-48m-320 0H48m355.08 147.08l-33.94-33.94M142.86 142.86l-33.94-33.94'
1717
/>
1818
<circle
1919
cx='256'
2020
cy='256'
2121
r='80'
2222
fill='none'
23-
stroke-linecap='round'
24-
stroke-miterlimit='10'
25-
stroke-width='32'
23+
strokeLinecap='round'
24+
strokeMiterlimit='10'
25+
strokeWidth='32'
2626
/>
2727
</svg>
2828
)

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,25 @@
3737
"katex": "^0.16.28",
3838
"ky": "^1.14.3",
3939
"lqip-modern": "^2.2.1",
40-
"next": "^16.1.6",
41-
"notion-client": "^7.8.1",
42-
"notion-types": "^7.8.1",
43-
"notion-utils": "^7.8.1",
40+
"next": "^16.2.0",
41+
"notion-client": "^7.10.0",
42+
"notion-types": "^7.10.0",
43+
"notion-utils": "^7.10.0",
4444
"p-map": "^7.0.4",
4545
"p-memoize": "^8.0.0",
46-
"posthog-js": "^1.249.4",
46+
"posthog-js": "^1.362.0",
4747
"prismjs": "^1.30.0",
4848
"react": "^19.2.4",
4949
"react-body-classname": "^1.3.1",
5050
"react-dom": "^19.2.4",
51-
"react-notion-x": "^7.8.1",
51+
"react-notion-x": "^7.10.0",
5252
"react-tweet": "^3.3.0",
5353
"react-use": "^17.6.0",
5454
"rss": "^1.2.2"
5555
},
5656
"devDependencies": {
5757
"@fisch0920/config": "^1.4.0",
58-
"@types/node": "^25.2.3",
58+
"@types/node": "^25.5.0",
5959
"@types/prismjs": "^1.26.5",
6060
"@types/react": "^19.2.14",
6161
"@types/react-body-classname": "^1.1.10",

pages/_app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'katex/dist/katex.min.css'
33
// used for code syntax highlighting (optional)
44
import 'prismjs/themes/prism-coy.css'
55
// core styles shared by all of react-notion-x (required)
6-
import 'react-notion-x/src/styles.css'
6+
import 'react-notion-x/styles.css'
77
// global styles shared across the entire site
88
import 'styles/global.css'
99
// this might be better for dark mode

0 commit comments

Comments
 (0)