From a26ea9287f266e340204892eccc481fc54e7953f Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Sat, 26 Mar 2022 05:22:48 -0500 Subject: [PATCH] feat(spa): update server output for better SPA integration --- packages/astro/src/runtime/server/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts index d977219acd..d530f61737 100644 --- a/packages/astro/src/runtime/server/index.ts +++ b/packages/astro/src/runtime/server/index.ts @@ -273,7 +273,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr // Render a template if no fragment is provided. const needsAstroTemplate = children && !/<\/?astro-fragment\>/.test(html); const template = needsAstroTemplate ? `` : ''; - return markHTMLString(`${html ?? ''}${template}`); + return markHTMLString(`${html ?? ''}${template}`); } /** Create the Astro.fetchContent() runtime function. */ @@ -468,7 +468,7 @@ export async function renderHead(result: SSRResult): Promise { const styleChildren = !result._metadata.legacyBuild ? '' : style.children; return renderElement('style', { children: styleChildren, - props: { ...style.props, 'astro-style': true }, + props: { ...style.props, 'astro-style': result._metadata.legacyBuild ? true : undefined }, }); }); let needsHydrationStyles = false; @@ -480,11 +480,11 @@ export async function renderHead(result: SSRResult): Promise { } return renderElement('script', { ...script, - props: { ...script.props, 'astro-script': result._metadata.pathname + '/script-' + i }, + props: { ...script.props, 'astro-script': result._metadata.legacyBuild ? result._metadata.pathname + '/script-' + i : undefined }, }); }); if (needsHydrationStyles) { - styles.push(renderElement('style', { props: { 'astro-style': true }, children: 'astro-root, astro-fragment { display: contents; }' })); + styles.push(renderElement('style', { props: { 'astro-style': result._metadata.legacyBuild ? true : undefined }, children: 'astro-root, astro-fragment { display: contents; }' })); } const links = Array.from(result.links) .filter(uniqueElements)