Skip to content

Commit

Permalink
Merge branch 'main' into dev/static-page-get-path-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alextaing authored Nov 3, 2023
2 parents da55b5e + 8a7a60d commit 79f1b27
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/pages/src/common/src/template/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getHydrationTemplateDev = (
render(
{
Page: Component,
pageProps: ${JSON.stringify(props)},
pageProps: ${getPagePropsString(props)},
}
);
`;
Expand Down Expand Up @@ -76,12 +76,18 @@ export const getHydrationTemplate = (
render.render(
{
Page: component.default,
pageProps: ${JSON.stringify(props)},
pageProps: ${getPagePropsString(props)},
}
);
`;
};

const getPagePropsString = (props: TemplateRenderProps) => {
return `JSON.parse(decodeURIComponent("${encodeURIComponent(
JSON.stringify(props)
)}"))`;
};

const makeAbsolute = (path: string): string => {
if (!path.startsWith("/")) {
return "/" + path;
Expand Down

0 comments on commit 79f1b27

Please sign in to comment.