Fixed the broken search in nextjs-notion-starter-kit
Last updated on May 7, 2024 am
Last Update: Finally, I’ve decided to abandon the Next.js Notion starter kit for my website. Instead, I recommend trying out the solution of Notion + Elog + Hexo. It allows for easy DIY and offers better page speed. I’ll write an article to introduce it next time!
Reputation
Thanks to @Travis Fischer for bringing us this awesome project that combines Next.js and Notion. It makes building a custom website quite simple.
Reason
If your nextjs-notion-starter-kit
version is v2.0.0 or below, like my project is v2.0.0, you’ll find your search function is broken. This is because of the search API params was changed by Notion.
💡 As the pic shows, param sort turned
String
into anObject
.
Although the guy @Armster15 fixed this problem in the Project’s dependency react-notion-x@6.16.1
, but the npm version is still v6.16.0 until 17/10/2023.
Solve
We can not simply update the dependency version to solve this problem, I believe the author will fixed the issue in the future. but currently we need a hotfix. The way is quite simple:
1.find a package called patch-package
in npm, and install it.
1 |
|
2.add a post-install hook in package.json
, like this
1 |
|
3.download the patch file and put it into your project dir /patches
, as the pic shows.
Download The Patch File
File on Google Drive
file
[file](https://drive.google.com/file/d/17AQFkbqJVH53DGIKYGZBHGTH1w6Rgpzu/view)
4.Run npm i --legacy-peer-deps
again**,** the patches will apply to the node_modules
.
5.Test the your project in development, it works.