Skip to content
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

Feature/Add the file block #51

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ export interface File {
export interface FileBlock {
Type: string
File: {
External: File
External: External
}
}

export interface External {
Url: string
ExpiryTime?: string
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://developers.notion.com/reference/file-object
type: external の場合は expiry_time 持たなそうです。

}

export interface Code {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/notion/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ export async function getAllBlocksByBlockId(blockId: string): Promise<Block[]> {
if (Date.parse(block.Image.File.ExpiryTime) < Date.now()) {
block.Image = (await getBlock(block.Id)).Image
}
} else if (block.Type === 'file' && block.FileBlock && block.FileBlock.File && block.FileBlock.File.ExpiryTime) {
if (Date.parse(block.FileBlock.File.ExpiryTime) < Date.now()) {
} else if (block.Type === 'file' && block.FileBlock && block.FileBlock.File && block.FileBlock.File.External.ExpiryTime) {
if (Date.parse(block.FileBlock.File.External.ExpiryTime) < Date.now()) {
block.FileBlock = (await getBlock(block.Id)).FileBlock
}
}
Expand Down