1
import { Client } from '@notionhq/client';
2
import { NotionToMarkdown } from 'notion-to-md';
3
4
export async function main(appToken: string, pageId: string) {
5
return new Promise(async (resolve, reject) => {
6
let notion = new Client({
7
auth: appToken
8
});
9
const n2m = new NotionToMarkdown({ notionClient: notion });
10
const markdown = await n2m.pageToMarkdown(pageId)
11
.catch((err) => {
12
reject(err);
13
return
14
15
16
if (!markdown) {
17
reject("Failed to convert page to markdown");
18
19
}
20
resolve(n2m.toMarkdownString(markdown))
21
22
})
23