0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-04-07 23:41:43 -05:00

[ci] format

This commit is contained in:
Emanuele Stoppa 2025-03-18 09:34:59 +00:00 committed by astrobot-houston
parent 8c21663c4a
commit 1a9363745e
3 changed files with 20 additions and 16 deletions

View file

@ -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<string, string | undefined>} params - An object containing key-value pairs of route parameters.
*/
public insertPageRoute(route: string,component: AstroComponentFactory, params?: Record<string, string | undefined>) {
public insertPageRoute(
route: string,
component: AstroComponentFactory,
params?: Record<string, string | undefined>,
) {
const url = new URL(route, 'https://example.com/');
const routeData: RouteData = this.#createRoute(url, params ?? {}, 'page');
this.#pipeline.manifest.routes.push({

View file

@ -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<ComponentInstance> {
const page = this.#componentsInterner.get(routeData);
const page = this.#componentsInterner.get(routeData);
if (page) {
return page.page();
}

View file

@ -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)}<div>hello world</div>`,
head: () => render`
${renderComponent(
result,
'Fragment',
Fragment,
{ slot: 'head' },
{
default: () => render`<meta charset="utf-8">`,
},
)}
result,
'Fragment',
Fragment,
{ slot: 'head' },
{
default: () => render`<meta charset="utf-8">`,
},
)}
`,
},
)}`;