-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update Astro.slots API * fix: migrate Markdown to public `Astro.slots.render` API * chore: update internal AstroGlobal types * chore: add changeset * Update clean-bottles-drive.md * refactor(test): update slot tests to new syntax
- Loading branch information
1 parent
af075d8
commit ae8d925
Showing
5 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Update `Astro.slots` API with new public `has` and `render` methods. | ||
|
||
This is a backwards-compatible change—`Astro.slots.default` will still be `true` if the component has been passed a `default` slot. | ||
|
||
```ts | ||
if (Astro.slots.has("default")) { | ||
const content = await Astro.slots.render("default"); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/astro/test/fixtures/astro-slots/src/components/SlottedAPI.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
{Astro.slots.a && <div id="a"> | ||
{Astro.slots.has("a") && <div id="a"> | ||
<slot name="a" /> | ||
</div>} | ||
|
||
{Astro.slots.b && <div id="b"> | ||
{Astro.slots.has("b") && <div id="b"> | ||
<slot name="b" /> | ||
</div>} | ||
|
||
{Astro.slots.c && <div id="c"> | ||
{Astro.slots.has("c") && <div id="c"> | ||
<slot name="c" /> | ||
</div>} | ||
|
||
{Astro.slots.default && <div id="default"> | ||
{Astro.slots.has("default") && <div id="default"> | ||
<slot /> | ||
</div>} |