Skip to content

Commit f1d4375

Browse files
robinclaude
andcommitted
Fix TableOfContents for notion-client v7 and downgrade ESLint
- Update block value access in TableOfContents to handle v7's extra .value wrapper (block.value.value instead of block.value) - Add null guards to prevent crashes when page block is not found - Downgrade eslint to ^8.57.0 and eslint-config-next to ^13.5.6 to fix compatibility with Next.js 13 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7e76cd8 commit f1d4375

3 files changed

Lines changed: 220 additions & 354 deletions

File tree

‎components/Post/TableOfContents.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ export default function TableOfContents ({ blockMap, frontMatter, pageTitle, sho
88
let collectionId, page
99
if (pageTitle) {
1010
collectionId = Object.keys(blockMap.block)[0]
11-
page = blockMap.block[collectionId].value
11+
page = blockMap.block[collectionId]?.value?.value
1212
} else {
1313
collectionId = Object.keys(blockMap.collection)[0]
14-
page = Object.values(blockMap.block).find(block => block.value.parent_id === collectionId).value
14+
const foundBlock = Object.values(blockMap.block).find(block => block.value?.value?.parent_id === collectionId)
15+
page = foundBlock?.value?.value
1516
}
17+
if (!page) return null
1618
const nodes = getPageTableOfContents(page, blockMap)
1719
if (!nodes.length || !showScrollElement) return null
1820

@@ -22,7 +24,7 @@ export default function TableOfContents ({ blockMap, frontMatter, pageTitle, sho
2224
*/
2325
const getHeaderLevel = (node) => {
2426
// Get the type information of the corresponding block through blockMap
25-
const block = blockMap?.block?.[node.id]?.value
27+
const block = blockMap?.block?.[node.id]?.value?.value
2628
if (block?.type === 'header') return 1
2729
if (block?.type === 'sub_header') return 2
2830
if (block?.type === 'sub_sub_header') return 3

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"@tailwindcss/postcss": "^4.1.12",
4848
"@types/react": "^19.1.1",
4949
"dotenv-cli": "^10.0.0",
50-
"eslint": "^9.34.0",
51-
"eslint-config-next": "^15.5.2",
50+
"eslint": "^8.57.0",
51+
"eslint-config-next": "^13.5.6",
5252
"husky": "^9.1.7",
5353
"next-sitemap": "^4.2.3",
5454
"postcss": "^8.5.6",

0 commit comments

Comments
 (0)