[ci] format
This commit is contained in:
parent
890a2bc989
commit
af9ac3360b
3 changed files with 28 additions and 6 deletions
|
@ -506,11 +506,23 @@ async function generatePath(
|
||||||
onRequest as MiddlewareResponseHandler,
|
onRequest as MiddlewareResponseHandler,
|
||||||
apiContext,
|
apiContext,
|
||||||
() => {
|
() => {
|
||||||
return renderPage({ mod, renderContext, env, apiContext, isCompressHTML: settings.config.compressHTML });
|
return renderPage({
|
||||||
|
mod,
|
||||||
|
renderContext,
|
||||||
|
env,
|
||||||
|
apiContext,
|
||||||
|
isCompressHTML: settings.config.compressHTML,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
response = await renderPage({ mod, renderContext, env, apiContext, isCompressHTML: settings.config.compressHTML });
|
response = await renderPage({
|
||||||
|
mod,
|
||||||
|
renderContext,
|
||||||
|
env,
|
||||||
|
apiContext,
|
||||||
|
isCompressHTML: settings.config.compressHTML,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (!AstroError.is(err) && !(err as SSRError).id && typeof err === 'object') {
|
if (!AstroError.is(err) && !(err as SSRError).id && typeof err === 'object') {
|
||||||
|
|
|
@ -108,10 +108,16 @@ export type RenderPage = {
|
||||||
renderContext: RenderContext;
|
renderContext: RenderContext;
|
||||||
env: Environment;
|
env: Environment;
|
||||||
apiContext?: APIContext;
|
apiContext?: APIContext;
|
||||||
isCompressHTML?: boolean
|
isCompressHTML?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function renderPage({ mod, renderContext, env, apiContext, isCompressHTML = false }: RenderPage) {
|
export async function renderPage({
|
||||||
|
mod,
|
||||||
|
renderContext,
|
||||||
|
env,
|
||||||
|
apiContext,
|
||||||
|
isCompressHTML = false,
|
||||||
|
}: RenderPage) {
|
||||||
// Validate the page component before rendering the page
|
// Validate the page component before rendering the page
|
||||||
const Component = mod.default;
|
const Component = mod.default;
|
||||||
if (!Component)
|
if (!Component)
|
||||||
|
|
|
@ -40,7 +40,7 @@ async function iterableToHTMLBytes(
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
i++;
|
i++;
|
||||||
if (!/<!doctype html/i.test(String(chunk))) {
|
if (!/<!doctype html/i.test(String(chunk))) {
|
||||||
parts.append(`${isCompressHTML ? '<!DOCTYPE html>' : '<!DOCTYPE html>\n'}`, result);
|
parts.append(`${isCompressHTML ? '<!DOCTYPE html>' : '<!DOCTYPE html>\n'}`, result);
|
||||||
if (onDocTypeInjection) {
|
if (onDocTypeInjection) {
|
||||||
await onDocTypeInjection(parts);
|
await onDocTypeInjection(parts);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,11 @@ export async function renderPage(
|
||||||
if (isHTMLString(chunk)) {
|
if (isHTMLString(chunk)) {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
if (!/<!doctype html/i.test(String(chunk))) {
|
if (!/<!doctype html/i.test(String(chunk))) {
|
||||||
controller.enqueue(encoder.encode(`${isCompressHTML ? '<!DOCTYPE html>' : '<!DOCTYPE html>\n'}`));
|
controller.enqueue(
|
||||||
|
encoder.encode(
|
||||||
|
`${isCompressHTML ? '<!DOCTYPE html>' : '<!DOCTYPE html>\n'}`
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue