Skip to content

Commit 072dee1

Browse files
fix(container-reference): add/update API reference blocks (withastro#12511)
Co-authored-by: yanthomasdev <[email protected]>
1 parent 6b37a35 commit 072dee1

File tree

1 file changed

+53
-11
lines changed

1 file changed

+53
-11
lines changed

src/content/docs/en/reference/container-reference.mdx

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ This API is experimental and subject to breaking changes, even in [minor or patc
2020

2121
## `create()`
2222

23+
<p>
24+
25+
**Type:** `(options?: AstroContainerOptions) => Promise<experimental_AstroContainer>`
26+
</p>
27+
2328
Creates a new instance of the container.
2429

2530
```js
@@ -50,13 +55,21 @@ export type AddServerRenderer =
5055

5156
### `streaming` option
5257

53-
**Type:** `boolean`
58+
<p>
59+
60+
**Type:** `boolean`<br />
61+
**Default:** `false`
62+
</p>
5463

5564
Enables rendering components using [HTML streaming](/en/guides/on-demand-rendering/#html-streaming).
5665

5766
### `renderers` option
5867

59-
**Type:** `AddServerRenderer[]`
68+
<p>
69+
70+
**Type:** `AddServerRenderer[]`<br />
71+
**Default:** `[]`
72+
</p>
6073

6174
A list of loaded client renderers required by the component. Use this if your `.astro` component renders any [UI framework components](/en/guides/framework-components/) or MDX using an official Astro integration (e.g. React, Vue, etc.).
6275

@@ -106,15 +119,20 @@ import vueRenderer from "@astrojs/vue/server.js";
106119
import mdxRenderer from "@astrojs/mdx/server.js";
107120

108121
const container = await experimental_AstroContainer.create();
109-
container.addServerRenderer({renderer: vueRenderer});
110-
container.addServerRenderer({renderer: mdxRenderer});
122+
container.addServerRenderer({ renderer: vueRenderer });
123+
container.addServerRenderer({ renderer: mdxRenderer });
111124

112125
container.addServerRenderer({ renderer: reactRenderer });
113126
container.addClientRenderer({ name: "@astrojs/react", entrypoint: "@astrojs/react/client.js" });
114127
```
115128

116129
## `renderToString()`
117130

131+
<p>
132+
133+
**Type:** <code>(component: AstroComponentFactory; options?: <a href="#rendering-options">ContainerRenderOptions</a>) => Promise&lt;string&gt;</code>
134+
</p>
135+
118136
This function renders a specified component inside a container. It takes an Astro component as an argument and it returns a string that represents the HTML/content rendered by the Astro component.
119137

120138
```js
@@ -131,6 +149,11 @@ It also accepts an object as a second argument that can contain a [number of opt
131149

132150
## `renderToResponse()`
133151

152+
<p>
153+
154+
**Type:** <code>(component: AstroComponentFactory; options?: <a href="#rendering-options">ContainerRenderOptions</a>) => Promise&lt;Response&gt;</code>
155+
</p>
156+
134157
It renders a component, and it returns a `Response` object.
135158

136159
```js
@@ -154,15 +177,19 @@ export type ContainerRenderOptions = {
154177
request?: Request;
155178
params?: Record<string, string | undefined>;
156179
locals?: App.Locals;
157-
routeType?: "page" | "endpoint";
180+
routeType?: RouteType;
181+
partial?: boolean;
158182
};
159183
```
160184

161185
These optional values can be passed to the rendering function in order to provide additional information necessary for an Astro component to properly render.
162186

163187
### `slots`
164188

165-
**Type:** `Record<string, any>`
189+
<p>
190+
191+
**Type**: `Record<string, any>`
192+
</p>
166193

167194
An option to pass content to be rendered with [`<slots>`](/en/basics/astro-components/#slots).
168195

@@ -224,7 +251,10 @@ const result = await container.renderToString(Card, {
224251

225252
### `props` option
226253

227-
**Type:** `Record<string, unknown>`
254+
<p>
255+
256+
**Type**: `Record<string, unknown>`
257+
</p>
228258

229259
An option to pass [properties](/en/basics/astro-components/#component-props) for Astro components.
230260

@@ -252,7 +282,10 @@ const { name } = Astro.props;
252282

253283
### `request` option
254284

255-
**Type:** `Request`
285+
<p>
286+
287+
**Type**: `Request`
288+
</p>
256289

257290
An option to pass a `Request` with information about the path/URL the component will render.
258291

@@ -274,7 +307,10 @@ const result = await container.renderToString(Card, {
274307

275308
### `params` option
276309

277-
**Type:** `Record<string, string | undefined>`
310+
<p>
311+
312+
**Type**: `Record<string, string | undefined>`
313+
</p>
278314

279315
An object to pass information about the path parameter to an Astro component responsible for [generating dynamic routes](/en/guides/routing/#dynamic-routes).
280316

@@ -300,7 +336,10 @@ const result = await container.renderToString(LocaleSlug, {
300336

301337
### `locals` options
302338

303-
**Type:** `App.Locals`
339+
<p>
340+
341+
**Type**: `App.Locals`
342+
</p>
304343

305344
An option to pass information from [`Astro.locals`](/en/reference/api-reference/#locals) for rendering your component.
306345

@@ -341,7 +380,10 @@ test("User is out", async () => {
341380

342381
### `routeType` option
343382

344-
**Type:** `"page" | "endpoint"`
383+
<p>
384+
385+
**Type**: `RouteType`
386+
</p>
345387

346388
An option available when using `renderToResponse()` to specify that you are rendering an [endpoint](/en/guides/endpoints/):
347389

0 commit comments

Comments
 (0)