fix(hosting): propagate preview token in nav links + enrich pages with scraped content
Preview token propagation: - JavaScript in storefront base.html appends _preview query param to all internal links when in preview mode, so clicking nav items (Services, Contact, etc.) preserves the preview bypass Scraped content enrichment: - POC builder now appends first 5 scraped paragraphs to about/services/ projects pages, so the POC shows actual content from the prospect's site instead of just generic template text - Extracts tagline from second scraped heading Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -147,8 +147,16 @@ class PocBuilderService:
|
||||
context["meta_description"] = scraped["meta_description"]
|
||||
if scraped.get("paragraphs"):
|
||||
context["about_paragraph"] = scraped["paragraphs"][0]
|
||||
if scraped.get("headings") and not prospect.business_name:
|
||||
context["business_name"] = scraped["headings"][0]
|
||||
# Build rich content from scraped paragraphs for page bodies
|
||||
context["scraped_paragraphs_html"] = "\n".join(
|
||||
f"<p>{p}</p>" for p in scraped["paragraphs"][:5]
|
||||
)
|
||||
if scraped.get("headings"):
|
||||
if not prospect.business_name:
|
||||
context["business_name"] = scraped["headings"][0]
|
||||
# Use second heading as tagline if available
|
||||
if len(scraped["headings"]) > 1:
|
||||
context["tagline"] = scraped["headings"][1]
|
||||
except (json.JSONDecodeError, KeyError):
|
||||
pass
|
||||
|
||||
@@ -203,6 +211,16 @@ class PocBuilderService:
|
||||
if content_translations and not content:
|
||||
content = next(iter(content_translations.values()), "")
|
||||
|
||||
# Enrich with scraped paragraphs (append to template content)
|
||||
scraped_html = context.get("scraped_paragraphs_html", "")
|
||||
if scraped_html and slug in ("about", "services", "projects"):
|
||||
content = content + "\n" + scraped_html if content else scraped_html
|
||||
if content_translations:
|
||||
for lang_code in content_translations:
|
||||
content_translations[lang_code] = (
|
||||
content_translations[lang_code] + "\n" + scraped_html
|
||||
)
|
||||
|
||||
page = ContentPage(
|
||||
platform_id=platform_id,
|
||||
store_id=store_id,
|
||||
|
||||
@@ -220,6 +220,22 @@
|
||||
<a href="https://hostwizard.lu" style="color:white;text-decoration:none;padding:6px 16px;border:1px solid rgba(255,255,255,0.4);border-radius:6px;font-size:13px;" target="_blank">hostwizard.lu</a>
|
||||
</div>
|
||||
<style>header { margin-top: 48px !important; }</style>
|
||||
<script>
|
||||
// Propagate preview token to all internal links
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var params = new URLSearchParams(window.location.search);
|
||||
var token = params.get('_preview');
|
||||
if (!token) return;
|
||||
document.querySelectorAll('a[href]').forEach(function(a) {
|
||||
var href = a.getAttribute('href');
|
||||
if (href && (href.startsWith('/') || href.startsWith(window.location.origin)) && !href.startsWith('//')) {
|
||||
var url = new URL(href, window.location.origin);
|
||||
url.searchParams.set('_preview', token);
|
||||
a.setAttribute('href', url.pathname + url.search);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{# Mobile menu panel #}
|
||||
|
||||
Reference in New Issue
Block a user