This commit is contained in:
2026-04-09 07:47:38 +01:00
parent ab6fc3be26
commit eb0721f94b
47 changed files with 826 additions and 136 deletions
@@ -4,28 +4,28 @@ import { log } from "../../../utils/log";
type Params = {
file_path: string;
root_file_path?: string;
server_res?: any;
// server_res?: any;
};
export default function grabPageReactComponentString({
file_path,
root_file_path,
server_res,
// server_res,
}: Params): string | undefined {
try {
let tsx = ``;
const server_res_json = JSON.stringify(
EJSON.stringify(server_res || {}) ?? "{}",
);
// const server_res_json = JSON.stringify(
// EJSON.stringify(server_res || {}) ?? "{}",
// );
if (root_file_path) {
tsx += `import Root from "${root_file_path}"\n`;
}
tsx += `import Page from "${file_path}"\n`;
tsx += `export default function Main() {\n\n`;
tsx += `const props = JSON.parse(${server_res_json})\n\n`;
tsx += `export default function Main({...props}) {\n\n`;
// tsx += `const props = JSON.parse(${server_res_json})\n\n`;
tsx += ` return (\n`;
if (root_file_path) {
tsx += ` <Root {...props}><Page {...props} /></Root>\n`;