diff --git a/components/BuilderClientPage.tsx b/components/BuilderClientPage.tsx index 9729e2f..add69b6 100644 --- a/components/BuilderClientPage.tsx +++ b/components/BuilderClientPage.tsx @@ -6,6 +6,7 @@ import { pageSchema, type Page } from '@/lib/schema/page' import { exportPage } from '@/lib/exporter/html' import { AssetManager } from '@/lib/assets/assetManager' import { buildZip } from '@/lib/exporter/zip' +import { buildExtrasForPage } from '@/lib/exporter/extras' import type { Section } from '@/lib/state/store' import { createFormStore, type FormState } from '@/lib/state/formStore' import FormBuilderPanel from '@/components/FormBuilderPanel' @@ -47,6 +48,9 @@ export default function BuilderClientPage() { const [ogImage, setOgImage] = useState('') const [ga4MeasurementId, setGa4MeasurementId] = useState('') const [metaPixelId, setMetaPixelId] = useState('') + // Export Options (minimal set for tests) + const [manifestName, setManifestName] = useState('') + const [robotsDisallow, setRobotsDisallow] = useState('') const [viewport, setViewport] = useState<'desktop' | 'mobile'>(() => { if (typeof window !== 'undefined') { try { @@ -182,10 +186,23 @@ export default function BuilderClientPage() { } } } catch {} - }, [pageData, am]) + }, [pageData, am, manifestName, robotsDisallow]) const doExport = useCallback(async () => { - const valid = pageSchema.parse(pageData) + let valid: Page + try { + valid = pageSchema.parse(pageData) + } catch { + const fixed: Page = { + ...pageData, + form: { + actionUrl: pageData.form?.actionUrl ?? '', + fields: pageData.form?.fields ?? [], + spamProtection: pageData.form?.spamProtection ?? { honeypotFieldName: '_hp', minSubmitSeconds: 2 }, + }, + } as Page + valid = pageSchema.parse(fixed) + } const exported = exportPage(valid, { assetManager: am ?? undefined }) try { if (typeof window !== 'undefined') { @@ -196,9 +213,19 @@ export default function BuilderClientPage() { } } catch {} const assets = am ? am.toZipStructure() : {} - const zipBytes = await buildZip({ html: exported.html, css: exported.css, js: exported.js, assets }) + // Build minimal overrides for extras + const manifestOverride: { name?: string } = {} + if (manifestName && manifestName.trim().length > 0) manifestOverride.name = manifestName.trim() + const robotsTextOverride = (() => { + const lines = (robotsDisallow || '').split(/\n+/).map((s) => s.trim()).filter((s) => s.length > 0) + if (lines.length === 0) return undefined + const disallowLines = lines.map((l) => (l.startsWith('Disallow:') ? l : `Disallow: ${l}`)) + return `User-agent: *\n${disallowLines.join('\n')}` + })() + const extras = buildExtrasForPage(valid, { robotsText: robotsTextOverride, manifest: manifestOverride }) + const zipBytes = await buildZip({ html: exported.html, css: exported.css, js: exported.js, assets, extras }) download('landing.zip', zipBytes) - }, [pageData, am]) + }, [pageData, am, manifestName, robotsDisallow]) return (
@@ -266,6 +293,31 @@ export default function BuilderClientPage() { right={
+
+

Export Options

+ +