# Create an OG and SEO review page from actual built metadata. from html.parser import HTMLParser from html import escape from pathlib import Path from urllib.parse import urlsplit import json import sys root = Path(sys.argv[1] if len(sys.argv) > 1 else '.vercel/output/static') class Head(HTMLParser): def __init__(self): super().__init__(); self.meta = {}; self.title = ''; self.in_title = False; self.canonical = ''; self.images = [] def handle_starttag(self, tag, attrs): attrs = dict(attrs) if tag == 'title': self.in_title = True if tag == 'meta': self.meta[attrs.get('property', attrs.get('name', ''))] = attrs.get('content', '') if tag == 'link' and attrs.get('rel') == 'canonical': self.canonical = attrs.get('href', '') if tag == 'img' and attrs.get('src'): self.images.append(attrs['src']) def handle_endtag(self, tag): if tag == 'title': self.in_title = False def handle_data(self, data): if self.in_title: self.title += data rows = [] home = None for file in sorted(root.rglob('index.html')): head = Head(); head.feed(file.read_text()) route = urlsplit(head.canonical).path if route == '/': home = head rows.append(f'
{escape(route)}

{escape(head.title)}

{escape(head.meta["description"])}

Social title
{escape(head.meta["og:title"])}
Canonical
{escape(head.canonical)}
') image_url = urlsplit(home.meta['og:image']) image_path = image_url.path + ('?' + image_url.query if image_url.query else '') html = '''OG & SEO review — PulseCanvas Studio

PulseCanvas Studio · Production review

Your next first impression.

Review the new social image and metadata for all 11 pages. The new OG image, metadata, and SEO fixes are now deployed to production.

''' html += f'{escape(home.meta[
1200 × 630 · PNG · Open Graph + XOpen full image

How the homepage could appear

PULSECANVAS.AI

{escape(home.meta["og:title"])}

{escape(home.meta["og:description"])}

Illustrative social preview. Platforms may crop images and shorten text.

PulseCanvas Studio
https://pulsecanvas.ai

{escape(home.title)}

{escape(home.meta["description"])}

Illustrative search snippet. Search engines choose the final title and description.

' html += '''

SEO checks & fixes

All 11 built pages passed technical checks.

The app has no published ratings or reviews, so it currently lacks the rating/review required for Google's software-app rich result. No ratings were invented. Passing technical checks does not guarantee indexing or rankings.

Metadata for every page

''' html += ''.join(rows) html += '''
''' review = Head() review.feed(html) for source in review.images: asset = root / urlsplit(source).path.lstrip('/') if not asset.is_file(): raise FileNotFoundError(f'Review image missing from deployment package: {source}') (root / 'og-review.html').write_text(html) # Vercel package: mark the page noindex in its routes (Cloudflare does this in _headers). config_path = Path('.vercel/output/config.json') if config_path.exists(): config = json.loads(config_path.read_text()) if not any(route.get('src') == '^/og-review\\.html$' for route in config['routes']): config['routes'].insert(0, {'src': '^/og-review\\.html$', 'headers': {'X-Robots-Tag': 'noindex, nofollow'}, 'continue': True}) config_path.write_text(json.dumps(config, indent=2)+'\n') print('OG and SEO review page created at /og-review.html.')