vike icon indicating copy to clipboard operation
vike copied to clipboard

Make original `pageContext` accessible to error page

Open brillout opened this issue 2 years ago • 2 comments

Description

Use case: i18n, see https://github.com/brillout/vite-plugin-ssr/discussions/1110.

In principle, it should be possible to make the original pageContext (of the page that failed to render) available to the error page's pageContext, e.g. at pageContext.pageContextOriginal.

Ideally, it should be automatically merged to the error pageContext so that it "just works", while preserving a pristine pageContext at pageContext.pageContextError.

See also:

  • https://github.com/vikejs/vike/issues/1846
  • https://github.com/vikejs/vike/issues/1268

brillout avatar Sep 08 '23 11:09 brillout

Alternatively instead of merging, you could make the original pageContext available on the error's pageContext.originalPageContext.

fvanwijk avatar Sep 11 '23 07:09 fvanwijk

Actually, in general, I'm thinking the best is to do both: merge everything into pageContext while providing a pageContext.from. See https://github.com/vikejs/vike/issues/1268.

brillout avatar Sep 11 '23 09:09 brillout