2週間に一度の定期更新です。概要説明の後、template_mentions については検証しておきます。

概要説明

新しい変更について読んでください。

検証

テンプレートメンションとはテンプレートにのみ記述できるメンションで、現在は @Today , @Now , @me のみがサポートされています。NotionRubyMapping のテストデータベースにテンプレートを作成し、これらを記載してみました。これを retrieve_page で取得してみます。

curl '<https://api.notion.com/v1/pages/88f4a106b84b4d359c2d256bcd55901f>' \\
    -H 'Notion-Version: 2022-02-22' \\
    -H 'Authorization: Bearer '"$NOTION_API_KEY"''

取得した JSON はこちら(一部省略しています)。TextTitle にある RichText の部分に今回の template_mention が 3 つ並んでいます。

{
  "object": "page",
  "id": "88f4a106-b84b-4d35-9c2d-256bcd55901f",
  (中略)
  "properties": {
    (中略)
    "TextTitle": {
      "id": "flUp",
      "type": "rich_text",
      "rich_text": [
        {
          "type": "mention",
          "mention": {
            "type": "template_mention",
            "template_mention": {
              "type": "template_mention_date",
              "template_mention_date": "today"
            }
          },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": "@Today",
          "href": null
        },
        {
          "type": "text",
          "text": {
            "content": " ",
            "link": null
          },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": " ",
          "href": null
        },
        {
          "type": "mention",
          "mention": {
            "type": "template_mention",
            "template_mention": {
              "type": "template_mention_date",
              "template_mention_date": "now"
            }
          },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": "@Now",
          "href": null
        },
        {
          "type": "text",
          "text": {
            "content": " ",
            "link": null
          },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": " ",
          "href": null
        },
        {
          "type": "mention",
          "mention": {
            "type": "template_mention",
            "template_mention": {
              "type": "template_mention_user",
              "template_mention_user": "me"
            }
          },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": "@Me",
          "href": null
        },
        {
          "type": "text",
          "text": {
            "content": " ",
            "link": null
          },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": " ",
          "href": null
        }
      ]
    },
    (中略)
  },
  "url": "<https://www.notion.so/template-88f4a106b84b4d359c2d256bcd55901f>"
}

これを受けて NotionRubyMapping に template_mention を追加しています。明日公開できると思います。


Notion API Changelog まとめ