Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Jan 23, 2025
1 parent 3299211 commit 4cc172d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
4 changes: 2 additions & 2 deletions vike/__internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import { PageConfigRuntime } from '../shared/page-configs/PageConfig.js'
*/
async function getPagesAndRoutes() {
setNodeEnvProduction()
const renderContext = getGlobalContext()
const globalContext = getGlobalContext()
const {
//
pageRoutes,
pageFilesAll,
pageConfigs,
allPageIds
} = renderContext
} = globalContext
return {
pageRoutes,
pageFilesAll,
Expand Down
3 changes: 1 addition & 2 deletions vike/node/prerender/runPrerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,8 @@ async function prerender404(
) {
if (!Object.values(prerenderedPageContexts).find(({ urlOriginal }) => urlOriginal === '/404')) {
let result: Awaited<ReturnType<typeof prerender404Page>>
const globalContext = getGlobalContext()
try {
result = await prerender404Page(globalContext, prerenderContext.pageContextInit)
result = await prerender404Page(prerenderContext.pageContextInit)
} catch (err) {
assertIsNotAbort(err, 'the 404 page')
throw err
Expand Down
15 changes: 3 additions & 12 deletions vike/node/runtime/renderPage/renderPageAlreadyRouted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export { renderPageAlreadyRouted }
export { prerenderPage }
export { prerender404Page }
export { getPageContextInitEnhanced }
export type { RenderContext }
export type { PageContextAfterRender }
export type { PageContextInitEnhanced }

Expand Down Expand Up @@ -131,8 +130,9 @@ async function prerenderPage(
}
}

async function prerender404Page(renderContext: RenderContext, pageContextInit_: Record<string, unknown> | null) {
const errorPageId = getErrorPageId(renderContext.pageFilesAll, renderContext.pageConfigs)
async function prerender404Page(pageContextInit_: Record<string, unknown> | null) {
const globalContext = getGlobalContext()
const errorPageId = getErrorPageId(globalContext.pageFilesAll, globalContext.pageConfigs)
if (!errorPageId) {
return null
}
Expand Down Expand Up @@ -232,12 +232,3 @@ function getPageContextInitEnhanced(

return pageContextInitEnhanced
}

type RenderContext = {
pageFilesAll: PageFile[]
pageConfigs: PageConfigRuntime[]
pageConfigGlobal: PageConfigGlobalRuntime
allPageIds: string[]
pageRoutes: PageRoutes
onBeforeRouteHook: Hook | null
}

0 comments on commit 4cc172d

Please sign in to comment.