Skip to content

公开 API

获取评论列表

获取指定页面的评论列表。

请求

http
GET /api/comments?path={path}&page={page}&pageSize={pageSize}

参数

参数类型必填说明
pathstring页面路径
pagenumber页码,默认 1
pageSizenumber每页数量,默认 10

响应示例

json
{
  "success": true,
  "data": {
    "comments": [
      {
        "id": 1,
        "path": "/blog/hello-world",
        "author": "张三",
        "email": "zhangsan@example.com",
        "content": "很棒的文章!",
        "parent_id": null,
        "status": "approved",
        "created_at": "2026-01-13T10:00:00Z",
        "avatar": "https://gravatar.com/avatar/..."
      }
    ],
    "total": 1,
    "page": 1,
    "pageSize": 10
  }
}

提交评论

提交新评论。

请求

http
POST /api/comments
Content-Type: application/json

请求体

json
{
  "path": "/blog/hello-world",
  "author": "张三",
  "email": "zhangsan@example.com",
  "content": "很棒的文章!",
  "parent_id": null
}

参数说明

参数类型必填说明
pathstring页面路径
authorstring评论者昵称
emailstring评论者邮箱
contentstring评论内容
parent_idnumber父评论 ID(回复时使用)

响应示例

json
{
  "success": true,
  "data": {
    "id": 1,
    "message": "评论提交成功,等待审核"
  }
}

基于 Cloudflare Workers 构建