otoyo/astro-notion-blog

Bug: localhostで起動すると、Cannot read properties of undefined (reading 'title')になる

harunonsystem opened this issue · 4 comments

不具合の概要

過去Closedされたissueに同じようなものがあったようにも見受けられるのですが
Cannot read properties of undefined (reading 'title')
になり、TableOfContents以外でも発生(column_listlink_previewなど)しております… ><
スクリーンショット 2023-01-29 4 29 26

Notion DB側の問題の可能性もあるので自分でも引き続き調べてみます👀

再現方法

  1. 本Repositoryをclone
  2. .envを入れて、yarn install && yarn dev
  3. 'http://localhost:3000/blog' を開く
  4. 添付画像のエラーが発生する

エラーログ

 error   Cannot read properties of undefined (reading 'title')
  File:
    /Users/harunon/astro/astro-notion-blog/src/lib/notion/client.ts:458:22
  Code:
    457 |         block.TableOfContents = tableOfContents
    > 458 |       }
          |                      ^
      459 |       break
      460 |   }
  Stacktrace:
TypeError: Cannot read properties of undefined (reading 'title')
    at _validPageObject (/src/lib/notion/client.ts:458:22)
    at eval (/src/lib/notion/client.ts:50:42)
    at Array.filter (<anonymous>)
    at getAllPosts (/src/lib/notion/client.ts:50:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.getAllTags (/src/lib/notion/client.ts:171:20)
    at async Promise.all (index 2)
    at async eval (/Users/harunon/astro/astro-notion-blog/src/pages/blog/index.astro:38:53)
    at async renderPage (file:///Users/harunon/astro/astro-notion-blog/node_modules/astro/dist/runtime/server/render/page.js:89:30)
    at async renderPage (file:///Users/harunon/astro/astro-notion-blog/node_modules/astro/dist/core/render/core.js:86:20)

04:33:34 AM [serve]    404                                   /sw.js (x2)

期待する挙動

/blog に正常に表示される

スクリーンショット

スクリーンショット 2023-01-29 4 29 26

otoyo commented

もしかすると、連携しているNotionデータベースの記事の列(Page 列)を別の名前に変えられましたか?
もしそうでなければ、連携しているNotionのデータベースのスクリーンショットをいただけますでしょうか?

元々別で使っていたデータベースを使っていたのでそれもあるかもです…

↓新規で別作成したデータベースで試してますが、同じエラーになってしまっています…(ここの名前Nameに変更したほうが良いでしょうか…?)
https://harunonsystem.notion.site/07da55fa76cf4ad58d09125bb9a9b0bc?v=b162e7d5484543ba99c35d082efd4024

スクリーンショット 2023-01-29 15 03 53

otoyo commented

列名と列の種類を手順にあるデータベースのテンプレートと同じにしていただければ大丈夫です。
https://github.com/otoyo/astro-notion-blog/blob/main/README.ja.md#%E3%82%B9%E3%83%86%E3%83%83%E3%83%97

あーなるほど!! 見落としていたようです、、表示確認できました。ありがとうございます!!