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

Fix Formatting and Update Dynamic Image Import Recipe for Vite 5 #5898

Merged
merged 3 commits into from
Dec 23, 2023

Conversation

VoxelMC
Copy link
Contributor

@VoxelMC VoxelMC commented Dec 23, 2023

Description (required)

As of Astro v4.0, which now uses Vite 5, the import.meta.glob<>() API no longer returns any and now returns unknown unless a generic is specified. This PR updates the dynamic image import recipe to reflect these changes. It also fixes indentation and unnecessary whitespace in the recipe.

Affected page: Modified

Related issues & labels (optional)

Copy link

vercel bot commented Dec 23, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Dec 23, 2023 3:54pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
docs-i18n ⬜️ Ignored (Inspect) Visit Preview Dec 23, 2023 3:54pm

@VoxelMC
Copy link
Contributor Author

VoxelMC commented Dec 23, 2023

Hello @Princesseuh! I was instructed to loop you in on this to ensure its accuracy. Please let me know if everything is A-OK! Thanks in advance for your time.

@sarah11918 sarah11918 added improve documentation Enhance existing documentation (e.g. add an example, improve description) help - confirm behaviour Walk through the example/issue and confirm this is a general behaviour, or a correct update to make. help wanted Issues looking for someone to run with them! labels Dec 23, 2023
Copy link
Member

@TheOtterlord TheOtterlord left a comment

Choose a reason for hiding this comment

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

Thanks a lot @VoxelMC!

I have one quick comment, but after running through the whole thing, verifying types and formatting, this looks good to me!

@TheOtterlord TheOtterlord merged commit 72139e7 into withastro:main Dec 23, 2023
7 of 8 checks passed
@Princesseuh
Copy link
Member

Princesseuh commented Dec 23, 2023

I would recommend adding error handling to this: <Image src={images[imagePath]()} alt={altText} /> because if you put an imagePath that doesn't exist, you'll get a cryptic error (image is not a function...) and we get a lot of support threads on that. Everything else looks good to me!

@TheOtterlord
Copy link
Member

Good call. I'll spin up an issue quickly to track this

ematipico pushed a commit that referenced this pull request Jan 26, 2024
* Fixes formatting and update according to v4

* Update src/content/docs/en/recipes/dynamically-importing-images.mdx

---------

Co-authored-by: Reuben Tier <64310361+TheOtterlord@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help - confirm behaviour Walk through the example/issue and confirm this is a general behaviour, or a correct update to make. help wanted Issues looking for someone to run with them! improve documentation Enhance existing documentation (e.g. add an example, improve description)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic Import of images using import.meta.glob() as described in the Documentation is causing error: ts(2322)
4 participants