[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,
|
||||
apiContext,
|
||||
() => {
|
||||
return renderPage({ mod, renderContext, env, apiContext, isCompressHTML: settings.config.compressHTML });
|
||||
return renderPage({
|
||||
mod,
|
||||
renderContext,
|
||||
env,
|
||||
apiContext,
|
||||
isCompressHTML: settings.config.compressHTML,
|
||||
});
|
||||
}
|
||||
);
|
||||
} 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) {
|
||||
if (!AstroError.is(err) && !(err as SSRError).id && typeof err === 'object') {
|
||||
|
|
|
@ -108,10 +108,16 @@ export type RenderPage = {
|
|||
renderContext: RenderContext;
|
||||
env: Environment;
|
||||
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
|
||||
const Component = mod.default;
|
||||
if (!Component)
|
||||
|
|
|
@ -40,7 +40,7 @@ async function iterableToHTMLBytes(
|
|||
if (i === 0) {
|
||||
i++;
|
||||
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) {
|
||||
await onDocTypeInjection(parts);
|
||||
}
|
||||
|
@ -154,7 +154,11 @@ export async function renderPage(
|
|||
if (isHTMLString(chunk)) {
|
||||
if (i === 0) {
|
||||
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