import path from "path"; import grabContants from "../../../utils/grab-constants"; import grabDirNames from "../../../utils/grab-dir-names"; import EJSON from "../../../utils/ejson"; import type { LivePageDistGenParams } from "../../../types"; import isDevelopment from "../../../utils/is-development"; export default async function genWebHTML({ component, pageProps, pageName, module, }: LivePageDistGenParams) { const { ClientRootElementIDName, ClientWindowPagePropsName } = await grabContants(); const { renderToString } = await import( path.join(process.cwd(), "node_modules", "react-dom", "server") ); const componentHTML = renderToString(component); const SCRIPT_SRC = path.join("/public/pages", pageName + ".js"); const CSS_SRC = path.join("/public/pages", pageName + ".css"); const { HYDRATION_DST_DIR } = grabDirNames(); const cssExists = await Bun.file(path.join(HYDRATION_DST_DIR, pageName + ".css")).exists(); let html = `\n`; html += `\n`; html += ` \n`; html += ` \n`; if (cssExists) { html += ` \n`; } if (isDevelopment()) { html += `\n`; } html += ` \n`; html += ` \n`; html += `
${componentHTML}
\n`; html += ` \n`; html += ` \n`; html += ` \n`; html += `\n`; return html; }