Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored and astrobot-houston committed Jun 5, 2023
1 parent 890a2bc commit af9ac33
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
16 changes: 14 additions & 2 deletions packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
10 changes: 8 additions & 2 deletions packages/astro/src/core/render/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions packages/astro/src/runtime/server/render/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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'}`
)
);
}
}
}
Expand Down

0 comments on commit af9ac33

Please sign in to comment.