From 98d785af1d8f1f1044db5e8b3364eec0e4d580be Mon Sep 17 00:00:00 2001 From: Jonathan Neal Date: Wed, 15 Sep 2021 11:27:59 -0400 Subject: Expose slots to components (#1368) * Expose slots to components via Astro.slots * test: Add Astro.slots API tests * docs: Document Astro.slots API * docs: Duplicate Astro.slots documentation to other api-reference markdown * Update proposal to use booleans, based upon RFC feedback * update implementation & tests based on request * changeset --- docs/src/pages/reference/api-reference.md | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'docs/src/pages/reference/api-reference.md') diff --git a/docs/src/pages/reference/api-reference.md b/docs/src/pages/reference/api-reference.md index 624ed2986..08178b4b5 100644 --- a/docs/src/pages/reference/api-reference.md +++ b/docs/src/pages/reference/api-reference.md @@ -86,6 +86,17 @@ const path = Astro.site.pathname;

Welcome to {path}

``` +### `Astro.slots` + +`Astro.slots` returns an object with any slotted regions passed into the current Astro file. + +```js +const { + heading as headingSlot, // true or undefined, based on whether `<* slot="heading">` was used. + default as defaultSlot, // true or undefined, based on whether `<* slot>` or `<* default>` was used. +} = Astro.slots; +``` + ## `getStaticPaths()` If a page uses dynamic params in the filename, that component will need to export a `getStaticPaths()` function. -- cgit v1.2.3