diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts index 777a5deb20..4169944005 100644 --- a/packages/astro/src/container/index.ts +++ b/packages/astro/src/container/index.ts @@ -13,6 +13,7 @@ import { getParts } from '../core/routing/manifest/parts.js'; import { getPattern } from '../core/routing/manifest/pattern.js'; import { validateSegment } from '../core/routing/manifest/segment.js'; import type { AstroComponentFactory } from '../runtime/server/index.js'; +import { SlotString } from '../runtime/server/render/slot.js'; import type { ComponentInstance } from '../types/astro.js'; import type { AstroMiddlewareInstance, MiddlewareHandler, Props } from '../types/public/common.js'; import type { AstroConfig, AstroUserConfig } from '../types/public/config.js'; @@ -26,7 +27,6 @@ import type { SSRResult, } from '../types/public/internal.js'; import { ContainerPipeline } from './pipeline.js'; -import { SlotString } from '../runtime/server/render/slot.js'; /** Public type, used for integrations to define a renderer for the container API */ export type ContainerRenderer = { @@ -540,16 +540,20 @@ export class experimental_AstroContainer { } /** - * It stores an Astro **page** route. The first argument, `route`, gets associated to the `component`. + * It stores an Astro **page** route. The first argument, `route`, gets associated to the `component`. * - * This function can be useful when you want to render a route via `AstroContainer.renderToString`, where that + * This function can be useful when you want to render a route via `AstroContainer.renderToString`, where that * route eventually renders another route via `Astro.rewrite`. * * @param {string} route - The URL that will render the component. * @param {AstroComponentFactory} component - The component factory to be used for rendering the route. * @param {Record} params - An object containing key-value pairs of route parameters. */ - public insertPageRoute(route: string,component: AstroComponentFactory, params?: Record) { + public insertPageRoute( + route: string, + component: AstroComponentFactory, + params?: Record, + ) { const url = new URL(route, 'https://example.com/'); const routeData: RouteData = this.#createRoute(url, params ?? {}, 'page'); this.#pipeline.manifest.routes.push({ diff --git a/packages/astro/src/container/pipeline.ts b/packages/astro/src/container/pipeline.ts index 6e927c2e5b..7cf17a3fb0 100644 --- a/packages/astro/src/container/pipeline.ts +++ b/packages/astro/src/container/pipeline.ts @@ -90,7 +90,7 @@ export class ContainerPipeline extends Pipeline { // At the moment it's not used by the container via any public API async getComponentByRoute(routeData: RouteData): Promise { - const page = this.#componentsInterner.get(routeData); + const page = this.#componentsInterner.get(routeData); if (page) { return page.page(); } diff --git a/packages/astro/test/container.test.js b/packages/astro/test/container.test.js index 3a46b610dd..e7b01644b0 100644 --- a/packages/astro/test/container.test.js +++ b/packages/astro/test/container.test.js @@ -3,6 +3,7 @@ import { before, describe, it } from 'node:test'; import { experimental_AstroContainer } from '../dist/container/index.js'; import { Fragment, + createAstro, createComponent, createHeadAndContent, maybeRenderHead, @@ -11,7 +12,6 @@ import { renderHead, renderSlot, renderTemplate, - createAstro } from '../dist/runtime/server/index.js'; import testAdapter from './test-adapter.js'; import { loadFixture } from './test-utils.js'; @@ -64,9 +64,9 @@ describe('Container', () => { const $$Astro = createAstro(); const Page = createComponent((result, props, slots) => { const Astro = result.createAstro($$Astro, props, slots); - return Astro.rewrite('/example') + return Astro.rewrite('/example'); }); - + const Example = createComponent((result) => { return render`${renderComponent( result, @@ -77,14 +77,14 @@ describe('Container', () => { default: () => render`${maybeRenderHead(result)}
hello world
`, head: () => render` ${renderComponent( - result, - 'Fragment', - Fragment, - { slot: 'head' }, - { - default: () => render``, - }, - )} + result, + 'Fragment', + Fragment, + { slot: 'head' }, + { + default: () => render``, + }, + )} `, }, )}`;