26 lines
1.4 KiB
TypeScript
26 lines
1.4 KiB
TypeScript
// Bundled (esbuild) by scripts/e2e-color-system.mjs and run in Node: what a publish of a saved project.json
|
|
// emits through the FRONTEND path (renderPublished = the editor Preview document), plus the pieces the
|
|
// BACKEND path receives (the composed body HTML), so the two heads can be compared.
|
|
import { exportBodyHtml, exportComposedPreviewHtml } from '../src/utils/html-export';
|
|
|
|
function bodies(project: any, pageIdx: number) {
|
|
const page = project.pages_craft_state[pageIdx];
|
|
const hdr = project.header_craft_state ? exportBodyHtml(project.header_craft_state, 'header').html : '';
|
|
const ftr = project.footer_craft_state ? exportBodyHtml(project.footer_craft_state, 'footer').html : '';
|
|
const body = exportBodyHtml(page.craftState).html;
|
|
return { page, composed: hdr + body + ftr };
|
|
}
|
|
|
|
export function renderPublished(project: any, pageIdx: number): string {
|
|
const { page, composed } = bodies(project, pageIdx);
|
|
return exportComposedPreviewHtml(page.craftState, composed, {
|
|
title: page.name, includeFonts: true, headCode: project.design?.headCode, design: project.design,
|
|
});
|
|
}
|
|
|
|
/** The inputs handlePublish feeds generateCompiledHTML for a page. */
|
|
export function backendInputs(project: any, pageIdx: number) {
|
|
const { page, composed } = bodies(project, pageIdx);
|
|
return { title: page.name, css: '', html: composed, headCode: project.design?.headCode || '', design: project.design || {} };
|
|
}
|