1 | import { Client } from "npm:@notionhq/client"; |
2 | import type { CreatePageParameters } from "npm:@notionhq/client/2.2.4/build/src/api-endpoints.js"; |
3 |
|
4 |
|
5 | * Windmill script to create a new page in Notion |
6 | * Reference: https://developers.notion.com/reference/post-page |
7 | */ |
8 | type Notion = { |
9 | token: string; |
10 | }; |
11 | export async function main(auth: Notion, database_id: string, properties: object, children: object[] = []) { |
12 | const client = new Client({ auth: auth.token }); |
13 | return await client.pages.create({ |
14 | parent: {database_id}, |
15 | properties, |
16 | children: children as CreatePageParameters["children"], |
17 | }); |
18 | } |