Created
July 14, 2023 09:39
-
-
Save iceener/41ad0650d728b2e4389930d3187eaf49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { markdownToBlocks } from '@tryfabric/martian'; | |
import { NotionToMarkdown } from 'notion-to-md'; | |
@Controller('/api/tools') | |
export class ToolsController { | |
@Post('/markdown-notion') | |
async convert(@Body() body) { | |
return markdownToBlocks(body.markdown); | |
} | |
@Post('/notion-markdown') | |
async convertBlocksToMarkdown( | |
@Req() request, | |
@Body() body, | |
) { | |
const auth = request.headers.authorization; | |
const notionClient = new Client({auth}); | |
const n2m = new NotionToMarkdown({notionClient}); | |
const mdblocks = await n2m.pageToMarkdown(body.pageId); | |
const mdString = n2m.toMarkdownString(mdblocks); | |
return { | |
markdown: mdString, | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment