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