-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (33 loc) · 822 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { Client } = require("@notionhq/client");
const { config } = require("dotenv");
config();
const notion = new Client({ auth: process.env.NOTION_API_KEY });
const args = process.argv.slice(2);
const command = args[0];
async function createPage(pageId, pageName) {
try {
const response = await notion.pages.create({
parent: {
type: "page_id",
page_id: pageId,
},
properties: {
Name: {
title: [
{
text: {
content: pageName,
},
},
],
},
},
});
console.log(`Page created successfully with ID: ${response.id}`);
} catch (error) {
console.error("Failed to create page:", error.message);
}
}
if (command === "create") {
createPage(args[1], args[2]);
}