// The public-offer page renderer: splices the live catalog price list into the owner-edited offer // markdown and renders it with the SAME renderOfferHtml the landing build used to invoke (bundled // from ui/src/lib/offer). Kept out of server.mjs so the substitution is unit-testable without HTTP. import { renderOfferHtml } from '../dist/gameimage.mjs'; // pricingMarker is the token ui/legal/offer_ru.md carries at ยง4.4 where the price list belongs. It // mirrors the backend marker (backend/internal/payments/offer.go) and is replaced with the fetched // tables before rendering. export const pricingMarker = '<#pricing_template#>'; // renderOffer returns the standalone /offer/ HTML: the offer markdown with the pricing marker // replaced by pricingTables (the two markdown tables the backend projects from the active catalog), // rendered to a self-contained document. The replacement is literal (a function replacer) so a "$" // in a product title is never read as a replacement pattern; a missing marker leaves the text as is. export function renderOffer(offerMarkdown, pricingTables) { return renderOfferHtml(offerMarkdown.replace(pricingMarker, () => pricingTables)); }