Files
zeekayandHanzo Dev 0d44a0d422 Restore the landing's 3x3 products grid and draw the home with no scroll motion
hanzo.ai goes back to the landing hanzo-inc/app served before the split (6 Nov): the nine
products three by three, each card its own screen, and the old rhythm (80px sections,
26px headings, 14px ledes). The 3D scroll journey, the dock and stage, the on-this-page
spine, the MCP picker (its setup lives on docs.hanzo.ai) and the "ways" band are gone.

Every heading, figure and card is in the HTML as it stays: no word reveals, fade-ups,
count-ups, scroll parallax, idle canvas loop or calendar sweep. What moves answers a
pointer (the cards' lean, the hero's dots, devices and title light, the agents' lift);
model films load and play only under the pointer. The hero headline and device stage are
sized in CSS, so nothing shifts on hydration (CLS 0). Scrolling is native (Lenis removed).

The home is a server component; content.ts is split into agents, products, shell and
logos so client code carries only what it draws; the 404's page index and the opener's
WebGL context load on use. three and lenis are dropped.

Mobile, 4x CPU, ~9 Mbps: LCP 1.2s (live 5.1s), blocking ~0.5s (1.5s), script -21%.

Co-authored-by: Hanzo Dev <[email protected]>
2026-11-11 11:34:34 -08:00

76 lines
4.7 KiB
Python

"""Run from the repo root: python3 scripts/extract.py
Pull Hanzo's own markup and data from the captured page into content/{agents,products,shell,logos}.ts and hanzo.css (nothing rewritten but URLs)."""
import os, re, json
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.chdir(ROOT)
from bs4 import BeautifulSoup
h = open('source/home.html').read()
s = BeautifulSoup(h, 'html.parser')
# resolve Next.js streamed Suspense boundaries: <template id="B:x"> is filled by the hidden <div id="S:x">
for t in s.find_all('template', id=lambda v: v and v.startswith('B:')):
src = s.find(id='S:' + t['id'][2:])
if src:
for c in list(src.children): t.insert_before(c)
t.decompose()
PAGES = set(json.load(open('content/pages.json'))) | {'/'} if __import__('os').path.exists('content/pages.json') else {'/'}
def ab(x):
"""Links to pages in this repo stay site-relative; links to Hanzo's app (chat, pay, signup...) go to hanzo.ai.
Asset paths stay relative: they are Hanzo's /public files (copy them in; the preview server fetches them)."""
def fix(m):
path = m.group(2)
base = re.split(r'[?#]', path)[0].rstrip('/') or '/'
return m.group(1) + '="' + (path if base in PAGES else 'https://hanzo.ai' + path) + '"'
x = re.sub(r'(href)="(?:https://hanzo\.ai)?(/[^"]*)"', fix, str(x))
return re.sub(r'(src|poster|srcset)="https://hanzo\.ai/', r'\1="/', x)
secs = [t for t in s.find_all('section') if not t.find_parent(['section', 'footer', 'header'])]
def uniq_logos(sec):
seen, out = set(), []
for a in sec.find_all('a'):
img = a.find('img')
if not img or a.get('aria-label') in seen: continue
seen.add(a['aria-label']); out.append({'name': a['aria-label'], 'href': ab(f'href="{a["href"]}"')[6:-1], 'src': img['src']})
return out
C = {}
C['header'] = ab(s.find('header')); C['footer'] = ab(s.find('footer'))
C['backed'] = uniq_logos(secs[1]); C['trusted'] = uniq_logos(secs[12])
# agents that work with Hanzo: one icon each
seen, ag = set(), []
for a in s.find(id='compatible').find_all('a'):
l = a.get('aria-label') or ''
if l.endswith(' docs') and l not in seen:
seen.add(l); ico = a.find(['svg', 'img'])
ag.append({'name': l[:-5], 'href': a['href'] if a['href'].startswith('http') else 'https://hanzo.ai' + a['href'], 'icon': ab(ico) if ico else ''})
C['agents'] = ag
# nine products: their live screen fragment + name, address, actions
grid = s.find(id='products-title').find_parent('div').find_next_sibling('div')
P = []
for card in grid.find_all('div', recursive=False):
inner = card.find('div'); vis, foot = inner.find_all('div', recursive=False)[:2]
texts = [t for t in foot.stripped_strings]
acts = [a for a in [{'label': a.get_text(' ', strip=True), 'href': a['href'] if a['href'].startswith('http') else 'https://hanzo.ai' + a['href']} for a in foot.find_all('a')] if not a['label'].startswith(texts[0] + ' ')]
P.append({'name': texts[0], 'addr': texts[1], 'vis': ab(vis), 'acts': acts})
C['products'] = P
# open source: sparkline svgs of the tiles, the commit calendar and the repository cards, as Hanzo renders them
o = s.find(id='open-source')
spark = [ab(e) for e in o.find_all(attrs={'aria-label': re.compile(r'^(Commits|Merges) a (week|month|day)')})]
C['spark'] = spark
cards = []
for t in o.find_all(string=re.compile(r'^hanzoai/')):
el = t.parent
while el and 'Pushed' not in el.get_text(): el = el.parent
if el and ab(el) not in cards: cards.append(ab(el))
C['repos'] = cards
# one module per use, so a page's script carries only what it draws (components import the one they need)
for name, keys in (('agents', 'agents'), ('products', 'products'), ('shell', ('header', 'footer')), ('logos', ('backed', 'trusted'))):
v = C[keys] if isinstance(keys, str) else {k: C[k] for k in keys}
open(f'content/{name}.ts', 'w').write('export default ' + json.dumps(v, ensure_ascii=False) + ';\n')
print({k: (len(v) if isinstance(v, list) else len(v)) for k, v in C.items()}, [p['name'] for p in P], [a['name'] for a in ag])
# their stylesheet, fonts served locally
css = open('source/hanzo-a.css').read() + '\n' + open('source/hanzo-b.css').read() + '\n' + '\n'.join(re.findall(r'<style[^>]*>(.*?)</style>', h, re.S))
css = re.sub(r'url\(\.\./media/Zen-Variable[^)]*\)', 'url(/fonts/Zen-Variable.woff2)', css)
css = re.sub(r'url\(\.\./media/ZenMono-Variable[^)]*\)', 'url(/fonts/ZenMono-Variable.woff2)', css)
# fonts must be same-origin (browsers block cross-site fonts); download them into public/fonts with the hash dropped
css = re.sub(r'url\(\.\./media/([A-Za-z0-9-]+)\.[A-Za-z0-9_-]+\.woff2\)', r'url(/fonts/\1.woff2)', css)
css = css.replace('url(../media/', 'url(https://hanzo.ai/_next/static/media/')
open('public/hanzo.css', 'w').write(css); print('css', len(css))