23 lines
472 B
TypeScript
23 lines
472 B
TypeScript
const extractUrlFromFile = (
|
|
image:
|
|
| {
|
|
type?: 'external'
|
|
external: {
|
|
url: string
|
|
}
|
|
}
|
|
| {
|
|
type?: 'file'
|
|
file: {
|
|
url: string
|
|
expiry_time: string
|
|
}
|
|
},
|
|
) => {
|
|
if (image.type === 'external') return image.external.url
|
|
else if (image.type === 'file') return image.file.url
|
|
else throw new Error('Notion API returned unexpected result')
|
|
}
|
|
|
|
export default extractUrlFromFile
|