mirror of
https://github.com/davila7/claude-code-templates.git
synced 2026-09-19 01:30:23 +08:00
519fdf0950
The dashboard is on Cloudflare Pages with a 24h edge cache already in
place, but every island still downloaded the full ~1.9MB index (327KB
gz) — even the sidebars/plugins/collection pages that only need per-type
counts. This splits the index into purpose-built artifacts so the
browser fetches only what each surface needs.
Generator (scripts/generate_components_json.py):
- Decouple the docs and dashboard index writes (they were a byte copy).
docs/components.json keeps `security` (the legacy site renders it);
the dashboard index drops both `content` and `security` (unused there)
→ ~13% smaller.
- Emit dashboard/public/counts.json (per-type counts, ~150 bytes),
components/{type}.json (per-type slices), and search-index.json
(flat name/description/category/type/path for global search).
Dashboard islands:
- ComponentGrid loads only the active type via fetchComponentsByType,
re-fetching on type switch (per-type in-memory cache).
- SearchModal (Cmd+K) uses the lighter search-index.json.
- Sidebar + plugins index/detail + collection pages fetch counts.json
instead of the full index just to read array lengths.
- data.ts gains fetchComponentsByType/fetchSearchIndex (additive);
fetchComponents() stays for the SSR detail page and Discord bot.
Fix: SendToRepoModal read `match.content` off an index that no longer
carries content, so "Send to repo" produced empty PRs / threw "No
component content found". buildFileMap now pulls each item's content via
fetchComponentContent (the per-component files), which also removes its
full-index fetch.
_headers: cache/CORS blocks for counts.json, components/*, search-index.json.
Payload (gzip on-the-wire): sidebars/plugins/collection 327KB → ~124B;
grid default type (agents) 327KB → 145KB; Cmd+K 327KB → 260KB.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>