kerwanp / notion-render

A Javascript library to transform Notion API RichText object into HTML
https://notion-render-docs.vercel.app
Apache License 2.0
98 stars 2 forks source link

Just render rich text #8

Closed MickL closed 7 months ago

MickL commented 9 months ago

Hello,

I would like to render richtext fields of a page, e.g. I just want to render the "tester":

{
  "object": "page",
  // ...
  "properties": {
    // ...
    "tester": {
      "id": "...",
      "type": "rich_text",
      "rich_text": [
        {
          "type": "text",
          "text": {
            "content": "Hello\n",
            "link": null
          },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": "Hello\n",
          "href": null
        },
        {
          "type": "text",
          "text": {
            "content": "World",
            "link": null
          },
          "annotations": {
            "bold": true,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": "World",
          "href": null
        }
      ]
    },
  }
}

Should result into:

Hello<br><strong>World</strong>

Is this possible with this library?

kerwanp commented 8 months ago

Hey! It should already be the case

MickL commented 8 months ago

I dont know how. I ended up checking your source code at Github and just copying this function.