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

Download images alongside site files #16

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

mateomorris
Copy link
Contributor

@mateomorris mateomorris commented Jan 26, 2024

Not ready to merge yet - right now it downloads images in the page sections and swaps out their URLs with the relative image url.

To do

  • Handle child pages
  • Handle images in page/site fields
  • Only download uploaded images (i.e. images that live on Supabase)

Nice to have

  • Enable for Github uploads too

@@ -58,7 +58,7 @@

async function download_site() {
loading = true
const files = await build_site_bundle({ pages: $pages, symbols: $symbols })
const files = await build_site_bundle({ pages: $pages, symbols: $symbols }, true)

Choose a reason for hiding this comment

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

Does this mean it will always download the assets? A checkbox next to the download button would allow both options, with or without images.


const updated_content = _.mapValues(content, (lang_value) =>
_.mapValues(lang_value, (field_value) => {
if (typeof field_value === 'object' && field_value.hasOwnProperty('alt')) {

Choose a reason for hiding this comment

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

Maybe this should check that field_value.url is not empty, i was getting errors when downloading the site

// Download images
const image_files = []
await Promise.all(
files_to_fetch.map(async ({ url, filename }) => {

Choose a reason for hiding this comment

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

this could be in a try catch since fetch can try to download forbidden assets, i have stumbled with this because i have some content with bad remote urls that can not be downloaded because of cors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants