Add more features. Customize HTML. Add server logic and other page module exports to __root
This commit is contained in:
@@ -14,21 +14,25 @@ export default function grabPageReactComponentString({
|
||||
}: Params): string | undefined {
|
||||
try {
|
||||
const target_path = pagePathTransform({ page_path: file_path });
|
||||
const target_root_path = root_file_path
|
||||
? pagePathTransform({ page_path: root_file_path })
|
||||
: undefined;
|
||||
|
||||
let tsx = ``;
|
||||
|
||||
const server_res_json = JSON.stringify(
|
||||
EJSON.stringify(server_res || {}) ?? "{}",
|
||||
);
|
||||
|
||||
if (root_file_path) {
|
||||
tsx += `import Root from "${root_file_path}"\n`;
|
||||
if (target_root_path) {
|
||||
tsx += `import Root from "${target_root_path}"\n`;
|
||||
}
|
||||
|
||||
tsx += `import Page from "${target_path}"\n`;
|
||||
tsx += `export default function Main() {\n\n`;
|
||||
tsx += `const props = JSON.parse(${server_res_json})\n\n`;
|
||||
tsx += ` return (\n`;
|
||||
if (root_file_path) {
|
||||
if (target_root_path) {
|
||||
tsx += ` <Root suppressHydrationWarning={true} {...props}><Page {...props} /></Root>\n`;
|
||||
} else {
|
||||
tsx += ` <Page suppressHydrationWarning={true} {...props} />\n`;
|
||||
|
||||
Reference in New Issue
Block a user