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
20 changes: 10 additions & 10 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@
"lint": "next lint"
},
"dependencies": {
"@notionhq/client": "^4.0.1",
"@notionhq/client": "^5.0.0",
"@xennis/react-notion-cms-fetch": "workspace:*",
"@xennis/react-notion-cms-render": "workspace:*",
"highlight.js": "^11.11.1",
"next": "15.4.7",
"next": "15.5.2",
"prismjs": "^1.30.0",
"react": "19.1.0",
"react-dom": "19.1.0"
"react": "19.1.1",
"react-dom": "19.1.1"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.1.11",
"@types/node": "^24.0.13",
"@tailwindcss/postcss": "^4.1.13",
"@types/node": "^24.3.1",
"@types/prismjs": "^1.26.5",
"@types/react": "19.1.8",
"@types/react-dom": "19.1.6",
"@types/react": "19.1.12",
"@types/react-dom": "19.1.9",
"postcss": "^8.5.6",
"tailwindcss": "^4.1.11",
"typescript": "^5.8.3"
"tailwindcss": "^4.1.13",
"typescript": "^5.9.2"
},
"pnpm": {
"overrides": {
Expand Down
12 changes: 11 additions & 1 deletion examples/nextjs/src/lib/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fetchDatabasePages, propsPlainTexts } from "@xennis/react-notion-cms-fe
import { Client } from "@notionhq/client"
import type { PageObjectResponse } from "@notionhq/client/build/src/api-endpoints"
import { downloadImageToPublicDir } from "./image"
import { isFullDatabase } from "@notionhq/client/build/src/helpers"

const notionClient = new Client({
auth: process.env.NOTION_ACCESS_TOKEN,
Expand All @@ -15,9 +16,18 @@ export type Page = {
icon: IconResponse
}

// Workaround for Notion v5.
const mustGetFirstDataSourceId = async (database_id: string): Promise<string> => {
const db = await notionClient.databases.retrieve({ database_id: database_id })
if (isFullDatabase(db) && db.data_sources.length > 0) {
return db.data_sources[0].id
}
throw Error("No data source found in database " + database_id)
}

export const getCachedPages = unstable_cache(async () => {
return fetchDatabasePages(notionClient, processPages, {
database_id: process.env.NOTION_PAGES_DB_ID!,
data_source_id: await mustGetFirstDataSourceId(process.env.NOTION_PAGES_DB_ID!),
page_size: 50,
})
}, ["cms-pages"])
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"devDependencies": {
"prettier": "^3.6.2",
"prettier-plugin-tailwindcss": "^0.6.14",
"typescript": "^5.8.3"
"typescript": "^5.9.2"
}
}
5 changes: 4 additions & 1 deletion packages/fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"clean": "tsc --clean"
},
"dependencies": {
"@notionhq/client": "^4.0.1"
"@notionhq/client": "^5.0.0"
},
"devDependencies": {
"@types/node": "^24.3.1"
}
}
6 changes: 3 additions & 3 deletions packages/fetch/src/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { type Client, isFullPage, iteratePaginatedAPI } from "@notionhq/client"
import { type PageObjectResponse, type QueryDatabaseParameters } from "@notionhq/client/build/src/api-endpoints"
import type { PageObjectResponse, QueryDataSourceParameters } from "@notionhq/client/build/src/api-endpoints"

export const fetchDatabasePages = async <T>(
client: Client,
processFn: (page: PageObjectResponse) => Promise<T | null>,
firstPageArgs: QueryDatabaseParameters,
firstPageArgs: QueryDataSourceParameters,
): Promise<Array<T>> => {
const result: Array<T> = []
for await (const item of iteratePaginatedAPI(client.databases.query, firstPageArgs)) {
for await (const item of iteratePaginatedAPI(client.dataSources.query, firstPageArgs)) {
if (isFullPage(item)) {
const fnResult = await processFn(item)
if (fnResult !== null) {
Expand Down
5 changes: 3 additions & 2 deletions packages/render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
"watch": "tsc --watch"
},
"dependencies": {
"@notionhq/client": "^4.0.1"
"@notionhq/client": "^5.0.0"
},
"devDependencies": {
"@types/react": "^19.1.8"
"@types/node": "^24.3.1",
"@types/react": "^19.1.12"
}
}
Loading