summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar matthewp <matthewp@users.noreply.github.com> 2023-07-27 18:44:29 +0000
committerGravatar astrobot-houston <fred+astrobot@astro.build> 2023-07-27 18:44:29 +0000
commit9fe1089e3e005c095ae253f6eaa84d33ae335b59 (patch)
tree23bbf8d6b07337eeabb3cc1971edb306724a13dc
parent7dbcbc86b3bd7e5458570906745364c9399d1a46 (diff)
downloadastro-9fe1089e3e005c095ae253f6eaa84d33ae335b59.tar.gz
astro-9fe1089e3e005c095ae253f6eaa84d33ae335b59.tar.zst
astro-9fe1089e3e005c095ae253f6eaa84d33ae335b59.zip
[ci] format
-rw-r--r--packages/astro/src/content/runtime.ts6
-rw-r--r--packages/astro/src/runtime/server/index.ts2
-rw-r--r--packages/astro/src/runtime/server/render/tags.ts28
3 files changed, 20 insertions, 16 deletions
diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts
index 112428587..b125eeaac 100644
--- a/packages/astro/src/content/runtime.ts
+++ b/packages/astro/src/content/runtime.ts
@@ -6,8 +6,8 @@ import {
createComponent,
createHeadAndContent,
renderComponent,
- renderUniqueScriptElement,
renderTemplate,
+ renderUniqueScriptElement,
renderUniqueStylesheet,
unescapeHTML,
type AstroComponentFactory,
@@ -303,7 +303,9 @@ async function render({
.join('');
}
if (Array.isArray(collectedScripts)) {
- scripts = collectedScripts.map((script: any) => renderUniqueScriptElement(result, script)).join('');
+ scripts = collectedScripts
+ .map((script: any) => renderUniqueScriptElement(result, script))
+ .join('');
}
let props = baseProps;
diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts
index 9acc41232..0fb85b3ce 100644
--- a/packages/astro/src/runtime/server/index.ts
+++ b/packages/astro/src/runtime/server/index.ts
@@ -27,8 +27,8 @@ export {
renderSlotToString,
renderTemplate,
renderToString,
- renderUniqueStylesheet,
renderUniqueScriptElement,
+ renderUniqueStylesheet,
voidElementNames,
} from './render/index.js';
export type {
diff --git a/packages/astro/src/runtime/server/render/tags.ts b/packages/astro/src/runtime/server/render/tags.ts
index dd38f27be..00a734814 100644
--- a/packages/astro/src/runtime/server/render/tags.ts
+++ b/packages/astro/src/runtime/server/render/tags.ts
@@ -10,42 +10,44 @@ export function renderScriptElement({ props, children }: SSRElement) {
}
export function renderUniqueScriptElement(result: SSRResult, { props, children }: SSRElement) {
- if(Array.from(result.scripts).some(s => {
- if(s.props.type === props.type && s.props.src === props.src) {
- return true;
- }
- if(!props.src && s.children === children) return true;
- })) return '';
+ if (
+ Array.from(result.scripts).some((s) => {
+ if (s.props.type === props.type && s.props.src === props.src) {
+ return true;
+ }
+ if (!props.src && s.children === children) return true;
+ })
+ )
+ return '';
const key = `script-${props.type}-${props.src}-${children}`;
- if(checkOrAddContentKey(result, key)) return '';
+ if (checkOrAddContentKey(result, key)) return '';
return renderScriptElement({ props, children });
-
}
export function renderUniqueStylesheet(result: SSRResult, sheet: StylesheetAsset) {
if (sheet.type === 'external') {
if (Array.from(result.styles).some((s) => s.props.href === sheet.src)) return '';
const key = 'link-external-' + sheet.src;
- if(checkOrAddContentKey(result, key)) return '';
+ if (checkOrAddContentKey(result, key)) return '';
return renderElement('link', {
props: {
rel: 'stylesheet',
- href: sheet.src
+ href: sheet.src,
},
- children: ''
+ children: '',
});
}
if (sheet.type === 'inline') {
if (Array.from(result.styles).some((s) => s.children.includes(sheet.content))) return '';
const key = `link-inline-` + sheet.content;
- if(checkOrAddContentKey(result, key)) return '';
+ if (checkOrAddContentKey(result, key)) return '';
return renderElement('style', { props: { type: 'text/css' }, children: sheet.content });
}
}
function checkOrAddContentKey(result: SSRResult, key: string): boolean {
- if(result._metadata.contentKeys.has(key)) return true;
+ if (result._metadata.contentKeys.has(key)) return true;
result._metadata.contentKeys.add(key);
return false;
}