'use strict'; const assert = require('assert'); const { getSerializableSpans } = require('../tracing/tracing-middleware'); const sanitizeHtml = require('../lib/sanitize-html'); const safeJson = require('../lib/safe-json'); const getDependenciesForEntryPointName = require('../lib/get-dependencies-for-entry-point-name'); const getFaviconAssetUrls = require('../lib/get-favicon-asset-urls'); async function renderPageHtml({ pageOptions, // Make sure you sanitize this before passing it to us bodyHtml, vmRenderContext, }) { assert(vmRenderContext); assert(pageOptions); assert(pageOptions.title); assert(pageOptions.entryPoint); assert(pageOptions.cspNonce); const { styles, scripts } = getDependenciesForEntryPointName(pageOptions.entryPoint); // Serialize the state for when we run the Hydrogen render again client-side to // re-hydrate the DOM const serializedMatrixPublicArchiveContext = JSON.stringify({ ...vmRenderContext, }); const serializableSpans = getSerializableSpans(); const serializedSpans = JSON.stringify(serializableSpans); // We shouldn't let some pages be indexed by search engines let maybeNoIndexHtml = ''; if (!pageOptions.shouldIndex) { maybeNoIndexHtml = ``; } const faviconMap = getFaviconAssetUrls(); const pageHtml = `
${maybeNoIndexHtml} ${sanitizeHtml(`