-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewrwxboostpage.js
60 lines (56 loc) · 1.57 KB
/
newrwxboostpage.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { Client } from "@notionhq/client"
import minimist from "minimist"
const notion = new Client({ auth: process.env.NOTION_KEY })
const databaseId = process.env.NOTION_DATABASE_ID
// get args from CLI
const argv = minimist(process.argv.slice(2));
const pageTitle1 = argv._[0];
const pageTitle2 = argv._[1];
const pageTitle = pageTitle1 + pageTitle2;
const videoLink = (argv._[2] != "" ? argv._[2] : null)
const materialsLink = argv._[3];
async function addItem(title, videoLink) {
try {
await notion.pages.create({
parent: { database_id: databaseId },
properties: {
Name: { title: [{ text: { "content": title } }] },
Class: { select: { name: "rwx-boost" } },
Type: { select: { name: "Lecture" } },
"Video link": { url: videoLink },
// this is broken - can't find an example in docs
Materials: { url: materialsLink },
},
children: [{
object: "block",
type: "paragraph",
paragraph: {
text: [{
type: "text",
text: {
content: "rwx boost course page",
link: { url: "https://github.com/rwxrob/boost" },
}
}],
}
},
{
object: "block",
type: "heading_1",
heading_1: {
text: [{
type: "text",
text: {
content: "Day " + pageTitle2
},
}],
},
}],
}).then(response => {
// console.log(response);
});
} catch (error) {
console.error(error.body)
}
}
addItem(pageTitle, videoLink);