-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotion_to_mark_down.ts
30 lines (26 loc) · 1.11 KB
/
notion_to_mark_down.ts
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
const { Client } = require("@notionhq/client");
const { NotionToMarkdown } = require("notion-to-md");
const fs = require('fs');
// or
// import {NotionToMarkdown} from "notion-to-md";
const notion = new Client({
auth: "secret_If3nUOfAsOruBJoPziCaEzaKrjh6DkqAciB7m91bRIQ",
config:{
separateChildPage:true, // default: false
}
});
const pages = [
{ name: "Readme", token: "6df40dd4e66744bea38fcbe4dc97af9c", filePath: "README.md" },
{ name: "Scheduling", token: "8819161ad7a840188d2c8266e1db324a", filePath: "scheduling/scheduling.md" },
{name: "Distributed Systems", token: "aec802de8876479983053855e304f549", filePath: "distributed_systems.md"},
{name: "Semaphores & Synchronization", token: "675352bdd02b40278698c99e4d0a38a7", filePath: "synchronisation/semaphores_&_synchronization.md"}
];
// NotionToMarkdown instance
const n2m = new NotionToMarkdown({ notionClient: notion });
(async () => {
for (const page of pages) {
const mdblocks = await n2m.pageToMarkdown(page.token);
const mdString = n2m.toMarkdownString(mdblocks);
fs.writeFileSync(page.filePath, mdString.parent, "utf8");
}
})();