withastro / compiler

The Astro compiler. Written in Go. Distributed as WASM.
Other
502 stars 59 forks source link

Fix various issues with slots #933

Closed MoustaphaDev closed 10 months ago

MoustaphaDev commented 10 months ago

Changes

Previously, using variables as slot names within loops was not possible because the slot object (specifically, the slot key) wasn't printed in the same location as the slotted elements.

This PR addresses this issue by refactoring the slot printing logic to ensure that the slot object is printed alongside the slotted elements when a dynamic slot name is used.

The other issues were fortuitously fixed with the refactor

Testing

Added test cases covering each issue

Docs

This wasn't possible before so we should probably document this. I'll make a docs PR

changeset-bot[bot] commented 10 months ago

🦋 Changeset detected

Latest commit: 97ce7ae135f43c8929d6cfa2cc7b1b53c10c962c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------- | ----- | | @astrojs/compiler | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

MoustaphaDev commented 10 months ago

!preview dynamic-slot-names

github-actions[bot] commented 10 months ago
 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--dynamic-slot-names" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--dynamic-slot-names tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 info @astrojs/compiler is being published because our local version (0.0.0-dynamic-slot-names-20240103232344) has not been published on npm 🦋 info Publishing "@astrojs/compiler" at "0.0.0-dynamic-slot-names-20240103232344" 🦋 success packages published successfully: 🦋 @astrojs/compiler@0.0.0-dynamic-slot-names-20240103232344 🦋 Creating git tag... 🦋 New tag: @astrojs/compiler@0.0.0-dynamic-slot-names-20240103232344
MoustaphaDev commented 10 months ago

!preview dynamic-slot-names

github-actions[bot] commented 10 months ago
 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--dynamic-slot-names" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--dynamic-slot-names tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 warn @astrojs/compiler is not being published because version 2.4.0 is already published on npm 🦋 warn No unpublished projects to publish
MoustaphaDev commented 10 months ago

!preview dynamic-slot-names

github-actions[bot] commented 10 months ago
 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--dynamic-slot-names" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--dynamic-slot-names tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 warn @astrojs/compiler is not being published because version 2.4.0 is already published on npm 🦋 warn No unpublished projects to publish
MoustaphaDev commented 10 months ago

!preview dynamic-slot-names

github-actions[bot] commented 10 months ago
 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--dynamic-slot-names" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--dynamic-slot-names tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 warn @astrojs/compiler is not being published because version 2.4.0 is already published on npm 🦋 warn No unpublished projects to publish
MoustaphaDev commented 10 months ago

!preview dynamic-slot-names

github-actions[bot] commented 10 months ago
 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--dynamic-slot-names" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--dynamic-slot-names tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 info @astrojs/compiler is being published because our local version (0.0.0-dynamic-slot-names-20240108101214) has not been published on npm 🦋 info Publishing "@astrojs/compiler" at "0.0.0-dynamic-slot-names-20240108101214" 🦋 success packages published successfully: 🦋 @astrojs/compiler@0.0.0-dynamic-slot-names-20240108101214 🦋 Creating git tag... 🦋 New tag: @astrojs/compiler@0.0.0-dynamic-slot-names-20240108101214
MoustaphaDev commented 10 months ago

!preview dynamic-slot-names

github-actions[bot] commented 10 months ago
 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--dynamic-slot-names" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--dynamic-slot-names tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 info @astrojs/compiler is being published because our local version (0.0.0-dynamic-slot-names-20240109194342) has not been published on npm 🦋 info Publishing "@astrojs/compiler" at "0.0.0-dynamic-slot-names-20240109194342" 🦋 success packages published successfully: 🦋 @astrojs/compiler@0.0.0-dynamic-slot-names-20240109194342 🦋 Creating git tag... 🦋 New tag: @astrojs/compiler@0.0.0-dynamic-slot-names-20240109194342
MoustaphaDev commented 10 months ago

!preview dynamic-slot-names

github-actions[bot] commented 10 months ago
 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--dynamic-slot-names" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--dynamic-slot-names tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 info @astrojs/compiler is being published because our local version (0.0.0-dynamic-slot-names-20240110221555) has not been published on npm 🦋 info Publishing "@astrojs/compiler" at "0.0.0-dynamic-slot-names-20240110221555" 🦋 success packages published successfully: 🦋 @astrojs/compiler@0.0.0-dynamic-slot-names-20240110221555 🦋 Creating git tag... 🦋 New tag: @astrojs/compiler@0.0.0-dynamic-slot-names-20240110221555
MoustaphaDev commented 10 months ago

!preview dynamic-slot-names

github-actions[bot] commented 10 months ago
 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--dynamic-slot-names" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--dynamic-slot-names tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 info @astrojs/compiler is being published because our local version (0.0.0-dynamic-slot-names-20240111152903) has not been published on npm 🦋 info Publishing "@astrojs/compiler" at "0.0.0-dynamic-slot-names-20240111152903" 🦋 success packages published successfully: 🦋 @astrojs/compiler@0.0.0-dynamic-slot-names-20240111152903 🦋 Creating git tag... 🦋 New tag: @astrojs/compiler@0.0.0-dynamic-slot-names-20240111152903
MoustaphaDev commented 10 months ago

Yes, this is backwards compatible as it doesn't break any current slot functionality. Only users on older Astro versions attempting to use this feature will encounter issues (which they of course did even before this release if they tried to). I can make a PR to docs to communicate that clearly