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

Refactor for payload image fetching #15

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

Conversation

martysweet
Copy link
Contributor

Hi again!

This is a slightly larger change that developed from assets not being downloaded when mentioned as part of payloads.

  • Reparsed based on the default eslint settings
  • Added image fetching from the Payload files. It was clear the URLs were being replaced, but it seems the assets hadn't been downloaded.
  • Pulled out urlsFromMatches as it (and the srcset logic) needs to be used in two places (PAGE and PAYLOAD)
  • Renamed some functions based to reflect usage more accurately

Let me know if anything needs to change!

@martysweet
Copy link
Contributor Author

Missed this simpler way of doing it https://github.com/d1urno/nuxt-image-extractor/pull/9/files
Would still need to pull out the URL parsing logic to support srcsets.

I think this use-case crops up occasionally (as with #9), the existing code certainly doesn't download the images, but URL replacement occurs. From my investigation, it looks like this happens when Nuxt doesn't complete the full rendering of the HTML. Instead, it depends on some JS to do the final rendering. Though I guess this shouldn't occur?

I can see this if I pull out the contents of HTML during build time, there are elements that are pulled from the payload when the page is rendered but do not exist in HTML during the page:generate call (hence the missing assets).

I am using the target: 'static' in my nuxt configuration with yarn generate. I'm not by any means a Nuxt expert! :D Any ideas?

@martysweet martysweet marked this pull request as draft April 19, 2021 11:29
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.

1 participant