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

    Function createBlock

    • Creates a code block.

      Parameters

      • options: string | Object | string[]

        A string or array of strings representing the code content, or an options object.

        • string
        • Object
          • rich_text

            The code content as a string, an array of strings, or an array of rich text objects.

          • caption

            The caption as a string, an array of strings, or an array of rich text objects.

          • language

            Programming language of the code block.

        • string[]

      Returns Object

      A code block object compatible with Notion's API.

      // Use with a string
      const simpleCode = block.code.createBlock("console.log('Give me all the bacon and eggs you have.');");

      // Use with an array of strings (multi-line snippet)
      const multiLineCode = block.code.createBlock([
      "let counter = 0;",
      "counter += 1;"
      ]);

      // Use with options object
      const complexCode = block.code.createBlock({
      rich_text: "const name = 'Monkey D. Luffy'\n console.log(`My name is ${name} and I will be king of the pirates!`)",
      language: "JavaScript",
      caption: "A simple JavaScript greeting function"
      });