Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored and astrobot-houston committed May 24, 2024
1 parent 98e0372 commit 5af99dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
7 changes: 4 additions & 3 deletions packages/astro/src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type {
AstroRenderer,
AstroUserConfig,
ComponentInstance,
MiddlewareHandler, Props,
MiddlewareHandler,
Props,
RouteData,
RouteType,
SSRLoadedRenderer,
Expand Down Expand Up @@ -73,12 +74,12 @@ export type ContainerRenderOptions = {

/**
* Allows to pass `Astro.props` to an Astro component:
*
*
* ```js
* container.renderToString(Endpoint, { props: { "lorem": "ipsum" } });
* ```
*/
props?: Props
props?: Props;
};

function createManifest(
Expand Down
22 changes: 13 additions & 9 deletions packages/astro/src/core/render-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type {
AstroGlobal,
AstroGlobalPartial,
ComponentInstance,
MiddlewareHandler, Props,
MiddlewareHandler,
Props,
RewritePayload,
RouteData,
SSRResult,
Expand Down Expand Up @@ -98,14 +99,17 @@ export class RenderContext {
): Promise<Response> {
const { cookies, middleware, pathname, pipeline } = this;
const { logger, routeCache, serverLike, streaming } = pipeline;
const props = Object.keys(this.props).length > 0 ? this.props : await getProps({
mod: componentInstance,
routeData: this.routeData,
routeCache,
pathname,
logger,
serverLike,
});
const props =
Object.keys(this.props).length > 0
? this.props
: await getProps({
mod: componentInstance,
routeData: this.routeData,
routeCache,
pathname,
logger,
serverLike,
});
const apiContext = this.createAPIContext(props);

this.counter++;
Expand Down
5 changes: 2 additions & 3 deletions packages/astro/test/container.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ describe('Container', () => {
assert.match(result, /Bar name/);
});


it('Renders props', async () => {
const Page = createComponent(
(result, props, _slots) => {
Expand All @@ -152,7 +151,7 @@ describe('Container', () => {
{
default: () => render`
${maybeRenderHead(result)}
${props.isOpen ? "Is open" : "Is closed"}
${props.isOpen ? 'Is open' : 'Is closed'}
`,
head: () => render`
${renderComponent(
Expand All @@ -175,7 +174,7 @@ describe('Container', () => {
const container = await experimental_AstroContainer.create();
const result = await container.renderToString(Page, {
props: {
isOpen: true
isOpen: true,
},
});

Expand Down

0 comments on commit 5af99dc

Please sign in to comment.