createAstroPagePartial() — astro Function Reference
Architecture documentation for the createAstroPagePartial() function in render-context.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 0007f436_547e_7fd2_f341_1a05d84a40a6["createAstroPagePartial()"] b7425a46_8c1f_1122_7ae3_a00e52db1d90["RenderContext"] 0007f436_547e_7fd2_f341_1a05d84a40a6 -->|defined in| b7425a46_8c1f_1122_7ae3_a00e52db1d90 92ee7d0b_4309_452e_10ee_49559c26b54e["createAstro()"] 92ee7d0b_4309_452e_10ee_49559c26b54e -->|calls| 0007f436_547e_7fd2_f341_1a05d84a40a6 8738ff41_9cb5_f0e0_abb2_ec740b39d0ad["getClientAddress()"] 0007f436_547e_7fd2_f341_1a05d84a40a6 -->|calls| 8738ff41_9cb5_f0e0_abb2_ec740b39d0ad a1e64bf7_a3cd_6346_6068_fe2858acbe2e["computeCurrentLocale()"] 0007f436_547e_7fd2_f341_1a05d84a40a6 -->|calls| a1e64bf7_a3cd_6346_6068_fe2858acbe2e 259723fe_8d99_f1f3_d6ad_afa57fadf1b8["computePreferredLocale()"] 0007f436_547e_7fd2_f341_1a05d84a40a6 -->|calls| 259723fe_8d99_f1f3_d6ad_afa57fadf1b8 5c3edeac_afc1_52c5_f90c_50d258bfdbfd["computePreferredLocaleList()"] 0007f436_547e_7fd2_f341_1a05d84a40a6 -->|calls| 5c3edeac_afc1_52c5_f90c_50d258bfdbfd style 0007f436_547e_7fd2_f341_1a05d84a40a6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/render-context.ts lines 665–771
createAstroPagePartial(
result: SSRResult,
apiContext: ActionAPIContext,
): Omit<AstroGlobal, 'props' | 'self' | 'slots'> {
const renderContext = this;
const { cookies, locals, params, pipeline, url } = this;
const { response } = result;
const redirect = (path: string, status = 302) => {
// If the response is already sent, error as we cannot proceed with the redirect.
if ((this.request as any)[responseSentSymbol]) {
throw new AstroError({
...AstroErrorData.ResponseSentError,
});
}
return new Response(null, { status, headers: { Location: path } });
};
const rewrite = async (reroutePayload: RewritePayload) => {
return await this.#executeRewrite(reroutePayload);
};
const callAction = createCallAction(apiContext);
return {
generator: ASTRO_GENERATOR,
routePattern: this.routeData.route,
isPrerendered: this.routeData.prerender,
cookies,
get session() {
if (this.isPrerendered) {
pipeline.logger.warn(
'session',
`Astro.session was used when rendering the route ${colors.green(this.routePattern)}, but it is not available on prerendered pages. If you need access to sessions, make sure that the page is server-rendered using \`export const prerender = false;\` or by setting \`output\` to \`"server"\` in your Astro config to make all your pages server-rendered by default. For more information, see https://docs.astro.build/en/guides/sessions/`,
);
return undefined;
}
if (!renderContext.session) {
pipeline.logger.warn(
'session',
`Astro.session was used when rendering the route ${colors.green(this.routePattern)}, but no storage configuration was provided. Either configure the storage manually or use an adapter that provides session storage. For more information, see https://docs.astro.build/en/guides/sessions/`,
);
return undefined;
}
return renderContext.session;
},
get clientAddress() {
return renderContext.getClientAddress();
},
get currentLocale() {
return renderContext.computeCurrentLocale();
},
params,
get preferredLocale() {
return renderContext.computePreferredLocale();
},
get preferredLocaleList() {
return renderContext.computePreferredLocaleList();
},
locals,
redirect,
rewrite,
request: this.request,
response,
site: pipeline.site,
getActionResult: createGetActionResult(locals),
get callAction() {
return callAction;
},
url,
get originPathname() {
return getOriginPathname(renderContext.request);
},
get csp(): APIContext['csp'] {
if (!pipeline.manifest.csp) {
pipeline.logger.warn(
'csp',
`Astro.csp was used when rendering the route ${colors.green(this.routePattern)}, but CSP was not configured. For more information, see https://docs.astro.build/en/reference/experimental-flags/csp/`,
);
return undefined;
}
return {
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does createAstroPagePartial() do?
createAstroPagePartial() is a function in the astro codebase, defined in packages/astro/src/core/render-context.ts.
Where is createAstroPagePartial() defined?
createAstroPagePartial() is defined in packages/astro/src/core/render-context.ts at line 665.
What does createAstroPagePartial() call?
createAstroPagePartial() calls 4 function(s): computeCurrentLocale, computePreferredLocale, computePreferredLocaleList, getClientAddress.
What calls createAstroPagePartial()?
createAstroPagePartial() is called by 1 function(s): createAstro.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free