[ci] format
This commit is contained in:
parent
7dbcbc86b3
commit
9fe1089e3e
3 changed files with 20 additions and 16 deletions
|
@ -6,8 +6,8 @@ import {
|
||||||
createComponent,
|
createComponent,
|
||||||
createHeadAndContent,
|
createHeadAndContent,
|
||||||
renderComponent,
|
renderComponent,
|
||||||
renderUniqueScriptElement,
|
|
||||||
renderTemplate,
|
renderTemplate,
|
||||||
|
renderUniqueScriptElement,
|
||||||
renderUniqueStylesheet,
|
renderUniqueStylesheet,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
type AstroComponentFactory,
|
type AstroComponentFactory,
|
||||||
|
@ -303,7 +303,9 @@ async function render({
|
||||||
.join('');
|
.join('');
|
||||||
}
|
}
|
||||||
if (Array.isArray(collectedScripts)) {
|
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;
|
let props = baseProps;
|
||||||
|
|
|
@ -27,8 +27,8 @@ export {
|
||||||
renderSlotToString,
|
renderSlotToString,
|
||||||
renderTemplate,
|
renderTemplate,
|
||||||
renderToString,
|
renderToString,
|
||||||
renderUniqueStylesheet,
|
|
||||||
renderUniqueScriptElement,
|
renderUniqueScriptElement,
|
||||||
|
renderUniqueStylesheet,
|
||||||
voidElementNames,
|
voidElementNames,
|
||||||
} from './render/index.js';
|
} from './render/index.js';
|
||||||
export type {
|
export type {
|
||||||
|
|
|
@ -10,16 +10,18 @@ export function renderScriptElement({ props, children }: SSRElement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderUniqueScriptElement(result: SSRResult, { props, children }: SSRElement) {
|
export function renderUniqueScriptElement(result: SSRResult, { props, children }: SSRElement) {
|
||||||
if(Array.from(result.scripts).some(s => {
|
if (
|
||||||
|
Array.from(result.scripts).some((s) => {
|
||||||
if (s.props.type === props.type && s.props.src === props.src) {
|
if (s.props.type === props.type && s.props.src === props.src) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!props.src && s.children === children) return true;
|
if (!props.src && s.children === children) return true;
|
||||||
})) return '';
|
})
|
||||||
|
)
|
||||||
|
return '';
|
||||||
const key = `script-${props.type}-${props.src}-${children}`;
|
const key = `script-${props.type}-${props.src}-${children}`;
|
||||||
if (checkOrAddContentKey(result, key)) return '';
|
if (checkOrAddContentKey(result, key)) return '';
|
||||||
return renderScriptElement({ props, children });
|
return renderScriptElement({ props, children });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderUniqueStylesheet(result: SSRResult, sheet: StylesheetAsset) {
|
export function renderUniqueStylesheet(result: SSRResult, sheet: StylesheetAsset) {
|
||||||
|
@ -30,9 +32,9 @@ export function renderUniqueStylesheet(result: SSRResult, sheet: StylesheetAsset
|
||||||
return renderElement('link', {
|
return renderElement('link', {
|
||||||
props: {
|
props: {
|
||||||
rel: 'stylesheet',
|
rel: 'stylesheet',
|
||||||
href: sheet.src
|
href: sheet.src,
|
||||||
},
|
},
|
||||||
children: ''
|
children: '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue