-
Notifications
You must be signed in to change notification settings - Fork 155
Notion API: fix the toggle convert & file name error #459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I made some changes to the |
| // If the result is empty or only whitespace after sanitization, return a default name | ||
| // This prevents creating files like ".md" (no name) or folders with only spaces | ||
| const trimmed = sanitized.trim(); | ||
| return trimmed || 'Untitled'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think generally this is a good change, however, in importDatabaseCore of the Notion API importer it would previously use Untitled Database if this function returned an empty value and now it will just return Untitled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, but compared to checking the return value at every sanitizeFileName function call, I don’t think it’s that important. Do you think this part must, as before, return a possible empty string value for backward compatibility?
src/util.ts
Outdated
| const sanitized = name | ||
| .replace(illegalRe, '') | ||
| .replace(controlRe, '') | ||
| .replace(controlRe, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I run npm run lint before each commit, but occasional spacing and comment indentation issues do occur, possibly due to my editor configuration; I’ll take a closer look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
|
|
||
| let headingText = ''; | ||
| let headingPrefix = ''; | ||
| let headingData: Heading1BlockObjectResponse['heading_1'] | Heading2BlockObjectResponse['heading_2'] | Heading3BlockObjectResponse['heading_3']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let headingData: Heading1BlockObjectResponse['heading_1'] | Heading2BlockObjectResponse['heading_2'] | Heading3BlockObjectResponse['heading_3']; | |
| let headingData: HeaderContentWithRichTextAndColorResponse; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. see: 8496eff
| let headingText = ''; | ||
| let headingPrefix = ''; | ||
| let headingData: Heading1BlockObjectResponse['heading_1'] | Heading2BlockObjectResponse['heading_2'] | Heading3BlockObjectResponse['heading_3']; | ||
| let isToggleable = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isToggleable can be defined after the if-block below without any casting required.
const isToggleable = headingData.is_toggleable || false;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that part was overly verbose, so I refactored it, along with the headingData above, see: 8496eff
In Notion, if a Toggle's title is a Heading, then it is a Heading block, not Toggle🥲