otoyo/astro-notion-blog

[Spec] Support File blocks

otoyo opened this issue · 1 comments

otoyo commented

Definition

  1. API endpoint is defined in src/pages/api/blocks/[id].ts
    • The endpoint is used for fetching the file URL(S3 signed URL) of the File blocks if the URL is expired
    • The endpoint allows GET /api/blocks/:id as a request
    • The endpoint returns JSON data of the block if the block type is 'file'
      • if the block type is not 'file', the endpoint respond 403 for security reasons
  2. Component is defined in src/components/notion-blocks/File.astro
    • The component displays a download link to the file like #51
    • The component make a request to the API to refresh the URL from front-end
    • The request is made IF...
      • the file URL is expired
      • the download link is clicked

Tips

  • The download link element should have the expiry time in a data attribute like data-expiry-time="2023-02-13T..."

TODO

  • Install adapter for Cloudflare worker
  • Add an API endpoint as /api/blocks/[id].ts
  • Define src/components/notion-blocks/File.astro
otoyo commented

Because downloading images to the local works well, I implemented file blocks also as the local download instead of the above.
#65