Closed mintcreamkitty closed 9 months ago
基本的な実装はいいねボタンと同じで、そのブランチが参考になります。 また、下記の記事もいいねボタンについてですが参考になると思います。
いいねボタン用に Like になっているところを Comments などに修正してください。
form
タグの中に <textarea name="comment"></textarea>
のようなタグを置くことでコメント入力欄を作ることができます。
https://developers.notion.com/docs/working-with-comments https://developers.notion.com/reference/create-a-comment
これを参考にすれば、
export async function createComments(pageId, comments): Promise<Post | null> { const response = await client.comments.create({ parent: { page_id: pageId }, rich_text: [ { text: { content: comments } } ] }); }
このように作ればいいでしょうか。
textraで入力されたことをcommentsとしてあれにUpdateするのかなと思いますが、 formの仕組みがわかりません。
<form onSubmit={createComments(pageId, comments)}>
<textarea
name="comments"
rows={6}></textarea>
<button
type="submit"
>
submit
</button>
onSubmit={createComments(pageId, comments)}
ではないですね...
私の実力ではまだ応用は難しいかもしれません。
まずはWebの基礎を学んだ方が良さそうです。 HTML、フォームの扱い、GETとPOST、サーバーサイドでの値の受け取り方について学習してみてください。
不具合の概要
不具合というより、 Nextjs notion blogでは使っていたcomment機能をつけるのに苦労してます。(notion comment)
コメントを見せるのはできるのですが、 コメントを formで入力するところで、 どうしたらいいか、分からなくなりました。
https://github.com/otoyo/astro-notion-blog/compare/main...example/like-button-on-vercel これのようにastroでコメントを使う例を教えていただけないでしょうか。