fix: images in RSS feed

Signed-off-by: Filipe Medeiros <hello@filipesm.eu>
This commit is contained in:
Filipe Medeiros 2022-12-25 02:32:42 +00:00
parent fead4dccea
commit af92c1f19a
Signed by: filipe
GPG key ID: 9533BD5467CC1E78
2 changed files with 15 additions and 5 deletions

View file

@ -209,6 +209,7 @@ export const rssBlockRenderMap: typeof blockRenderMap = {
src={getProxiedAssetUrl({ src={getProxiedAssetUrl({
blockId: block.id, blockId: block.id,
lastEditedTime: block.last_edited_time, lastEditedTime: block.last_edited_time,
withBaseUrl: true,
})} })}
/> />
{block.image.caption.length > 0 && ( {block.image.caption.length > 0 && (

View file

@ -1,15 +1,24 @@
// NOTE: this assumes that we are deploying on Vercel // NOTE: this assumes that we are deploying on Vercel
const getProxiedAssetUrl = ( const getProxiedAssetUrl = (
params: params:
| { blockId: string; lastEditedTime: string } | { blockId: string; lastEditedTime: string; withBaseUrl?: boolean }
| { pageId: string; propertyId?: string; lastEditedTime: string }, | {
pageId: string
propertyId?: string
lastEditedTime: string
withBaseUrl?: boolean
},
) => { ) => {
let path: string
if ('blockId' in params) if ('blockId' in params)
return `/api/notion-asset/block/${params.blockId}?lastEditedTime=${params.lastEditedTime}` path = `/api/notion-asset/block/${params.blockId}?lastEditedTime=${params.lastEditedTime}`
else if (!params.propertyId) else if (!params.propertyId)
return `/api/notion-asset/page/${params.pageId}?lastEditedTime=${params.lastEditedTime}` path = `/api/notion-asset/page/${params.pageId}?lastEditedTime=${params.lastEditedTime}`
else else
return `/api/notion-asset/page/${params.pageId}/${params.propertyId}?lastEditedTime=${params.lastEditedTime}` path = `/api/notion-asset/page/${params.pageId}/${params.propertyId}?lastEditedTime=${params.lastEditedTime}`
if (params.withBaseUrl) return `${process.env.NEXT_PUBLIC_SITE_URL}${path}`
else return path
} }
export default getProxiedAssetUrl export default getProxiedAssetUrl