diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 58fd77980698..19aa85695a9b 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -203,7 +203,7 @@ export interface AstroGlobal extends AstroGlobalPartial { */ has(slotName: string): boolean; /** - * Asychronously renders this slot and returns HTML + * Asynchronously renders this slot and returns a string * * Example usage: * ```astro @@ -216,6 +216,21 @@ export interface AstroGlobal extends AstroGlobalPartial { * * ``` * + * A second parameters can be used to pass arguments to a slotted callback + * + * Example usage: + * ```astro + * --- + * html = await Astro.slots.render('default', ["Hello", "World"]) + * --- + * ``` + * Each item in the array will be passed as an argument that you can use like so: + * ```astro + * + * {(hello, world) =>
{hello}, {world}!
} + *
+ * ``` + * * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots) */ render(slotName: string, args?: any[]): Promise; diff --git a/packages/astro/src/core/render/result.ts b/packages/astro/src/core/render/result.ts index 940868d994f1..dc5be4a079a5 100644 --- a/packages/astro/src/core/render/result.ts +++ b/packages/astro/src/core/render/result.ts @@ -100,7 +100,7 @@ class Slots { warn( this.#loggingOpts, 'Astro.slots.render', - `Expected second parameter to be an array, received a ${typeof args}` + `Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as a item of an array. Ex: Astro.slots.render('default', [["Hello", "World"]])` ); } else { if (expression) {