{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "notion-create-page", "type": "registry:item", "description": "Create a page in Notion", "dependencies": [], "files": [ { "path": "steps/notion-create-page.ts", "content": "/**\n * Create a page in Notion\n *\n * @param parentPageId - The parent page or database ID\n * @param title - The page title\n * @param content - Array of content blocks\n * @returns The created page with ID\n *\n * @env NOTION_API_KEY - Notion integration token\n */\n\nimport { FatalError } from \"workflow\"\n\ninterface CreatePageOptions {\n parentPageId: string\n title: string\n content?: Array<{\n type: \"paragraph\" | \"heading_1\" | \"heading_2\" | \"heading_3\"\n text: string\n }>\n}\n\nexport async function notionCreatePage({ parentPageId, title, content = [] }: CreatePageOptions) {\n \"use step\"\n\n const apiKey = process.env.NOTION_API_KEY\n if (!apiKey) {\n throw new FatalError(\"NOTION_API_KEY environment variable is required\")\n }\n\n if (!parentPageId || !title) {\n throw new FatalError(\"parentPageId and title are required\")\n }\n\n const children = content.map((block) => ({\n object: \"block\",\n type: block.type,\n [block.type]: {\n rich_text: [\n {\n type: \"text\",\n text: { content: block.text },\n },\n ],\n },\n }))\n\n const response = await fetch(\"https://api.notion.com/v1/pages\", {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"Notion-Version\": \"2022-06-28\",\n },\n body: JSON.stringify({\n parent: { page_id: parentPageId },\n properties: {\n title: {\n title: [\n {\n text: { content: title },\n },\n ],\n },\n },\n children,\n }),\n })\n\n if (!response.ok) {\n const error = await response.text()\n throw new Error(`Failed to create Notion page: ${error}`)\n }\n\n const data = await response.json()\n return {\n id: data.id,\n url: data.url,\n createdTime: data.created_time,\n }\n}\n", "type": "registry:file", "target": "steps/notion-create-page.ts" } ] }