0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-27 22:19:04 -05:00
astro/.changeset/soft-rabbits-draw.md
Emanuele Stoppa 2b6daa5840
fix(container): emit components as partials (#12239)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2024-10-16 14:07:59 +01:00

1.1 KiB

astro
patch

BREAKING CHANGE to the experimental Container API only

Changes the default page rendering behavior of Astro components in containers, and adds a new option partial: false to render full Astro pages as before.

Previously, the Container API was rendering all Astro components as if they were full Astro pages containing <!DOCTYPE html> by default. This was not intended, and now by default, all components will render as page partials: only the contents of the components without a page shell.

To render the component as a full-fledged Astro page, pass a new option called partial: false to renderToString() and renderToResponse():

import { experimental_AstroContainer as AstroContainer } from 'astro/container';
import Card from "../src/components/Card.astro";

const container = AstroContainer.create();

await container.renderToString(Card); // the string will not contain `<!DOCTYPE html>`
await container.renderToString(Card, { partial: false }); // the string will contain `<!DOCTYPE html>`