Notion Helper - v1.3.29
    Preparing search index...

    Function buildRichTextObj

    • Builds a Rich Text Object. See: https://developers.notion.com/reference/rich-text

      Parameters

      • input: string | Object

        The text content or input object. If string, the input can be normal text or an equation. If object, it can be a text, equation, or mention object.

      • Optionaloptions: {
            annotations?: {
                bold?: boolean;
                italic?: boolean;
                strikethrough?: boolean;
                underline?: boolean;
                code?: boolean;
                color?: string;
            };
            url?: string;
            type?: string;
        }

        Options for configuring the rich text object

        • Optionalannotations?: {
              bold?: boolean;
              italic?: boolean;
              strikethrough?: boolean;
              underline?: boolean;
              code?: boolean;
              color?: string;
          }

          Options for the Annotation object

          • Optionalbold?: boolean

            Bold text

          • Optionalitalic?: boolean

            Italic text

          • Optionalstrikethrough?: boolean

            Strikethrough text

          • Optionalunderline?: boolean

            Underlined text

          • Optionalcode?: boolean

            Code-style text

          • Optionalcolor?: string

            String specifying the text's color or background color. Options: "blue", "brown", "default", "gray", "green", "orange", "pink", "purple", "red", "yellow". All except "default" can also be used as a background color with "[color]_background" - example: "blue_background". See: https://developers.notion.com/reference/rich-text#the-annotation-object

        • Optionalurl?: string

          The URL for this object, if any. Creates a clickable link.

        • Optionaltype?: string

          An optional type for the Rich Text Object. Supports text, equation, and mention.

      • ...args: any[] = {}

      Returns Object[]

      • Array with a single Rich Text Object
      // Simple text
      buildRichTextObj("Hello World")

      // Text with URL
      buildRichTextObj("Watch this very important video", { url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ" })

      // Text with annotations
      buildRichTextObj("Bold and brown", {
      annotations: { bold: true, color: "brown" }
      })

      // Text with URL and annotations
      buildRichTextObj("Bold blue link", {
      url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
      annotations: { bold: true, color: "blue" }
      })

      // Equation
      buildRichTextObj("E = mc^2", { type: "equation" })

      // Mention
      buildRichTextObj({ type: "user", user: { id: "user_id" } }, { type: "mention" })
      buildRichTextObj({ type: "date", date: { start: "2025-01-01" } }, { type: "mention" })
      buildRichTextObj({ type: "database", database_id: "database_id" }, { type: "mention" })
      buildRichTextObj({ type: "page", page_id: "page_id" }, { type: "mention" })