Closed dharshatharan closed 2 years ago
Hey, great work. So I also gave this a try and referred to this https://github.com/instantish/martian/blob/master/src/notion/ where they defined the types making them independent of the notion SDK.
Dependency on notion SDK shouldn't be a problem, so I'll test it and let you know.
Oh, interesting. I guess there are pros and cons of being tied to notion as a dependency. But I think the advantage is that we try and stay up to date with the changes in types in the notion SDK.
I feel like for our use case, having the dependency might be a good thing. After all, we do depend on the notion SDK anyways.
Thanks for checking it out, looking forward to seeing what you think.
@dharshatharan facing few errors on compiling, related to block
argument in blockToMarkdown
and blocksToMarkdown
. I guess we can set it to any
for now or have to use @ts-ignore
.
@souvikinator Sorry I was not feeling well for the past few days. What are these errors you are talking about? Can you provide me with some steps to reproduce them?
Hey @dharshatharan it's absolutely fine.
So there are some type-related errors because of blocks: ListBlockChildrenResponseResults
and block: ListBlockChildrenResponseResult
ig? Properties like image
, videos
,equations
... do not exist in block
.
I don't get these errors you are talking about. I'm able to parse images, videos, and equations with no errors thrown and I don't get any type related errors showing up on VSCode. Can you double-check if you have the latest changes and have everything installed properly? Or if you're still having issues, maybe send me exact steps to replicate it or send me a screenshot?
Okay so I noticed that the latest commit is causing the issue however still can't figure out the reason.
In utils/notion.js
the getChildren()
takes extra argument called totalPage
to deal with pagination
https://github.com/souvikinator/notion-to-md/blob/d548ee42d0d3d03a2a1a58d3137f365aa5459f3b/utils/notion.js#L1
so we retrieve children like so (with extra args):
const response = await notionClient.blocks.children.list({
start_cursor: start_cursor,
page_size: pageSize,
block_id: block_id,
});
removing start_cursor
and page_size
fixes the issue:
seems like this is a type-related issue from the SDK side but I'm not sure.
Workaround:
const response = (await notionClient.blocks.children.list({
start_cursor,
page_size,
block_id,
})) as ListBlockChildrenResponse;
Also please make the required changes as per #9
I had to merge the latest changes from master and I performed the workaround you recommended. Hopefully, it works now.
Hey, @dharshatharan thanks for contributing. Did minor changes, and restructured the project. Will be releasing an update shortly.
Feature: Typescript support #3
Followed similar typescript setup to @notionhq/client (makenotion/notion-sdk-js) - https://github.com/makenotion/notion-sdk-js
Things to Note:
notion2md
toNotionToMarkdown
as classes/constructors should have an uppercase first letternotion-to-md.ts
file (line 147) to deal with a typescript indexing issueThings yet to be done:
Looking for feedback on this implementation :)