A string or array of strings representing the code content, or an options object.
The code content as a string, an array of strings, or an array of rich text objects.
The caption as a string, an array of strings, or an array of rich text objects.
Programming language of the code block.
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"
});
Creates a code block.