Skip to content

fix(wiki): prefix gacha iframe src with Astro base path#15

Merged
PanQiWei merged 1 commit into
PanQiWei:mainfrom
nanxingw:main
Apr 27, 2026
Merged

fix(wiki): prefix gacha iframe src with Astro base path#15
PanQiWei merged 1 commit into
PanQiWei:mainfrom
nanxingw:main

Conversation

@nanxingw
Copy link
Copy Markdown
Contributor

Summary

Fixes #14 — the Knowledge Atlas 抽卡 modal showed a "There isn't a GitHub Pages site here." 404 page instead of the picked card.

Root cause: In site/src/components/WikiAtlas.astro, the gacha iframe's src was hardcoded as /card-fragment/<lang>/<kind>/<slug>, missing the Astro base prefix. Locally (base="") it worked. On GitHub Pages — where the site lives under /advanced-agentic-dev-patterns/ — the iframe requested /card-fragment/... against the domain root, so Pages served its default 404 inside the modal (matching the screenshot in the issue).

Fix: Pass BASE through .gacha[data-base] (mirroring the existing data-lang channel for client-side script) and prepend it when building the iframe src.

Test plan

  • SITE_BASE=/advanced-agentic-dev-patterns npm run build succeeds (1077 pages built)
  • Emitted HTML carries data-base="/advanced-agentic-dev-patterns"; bundled JS uses ${k}/card-fragment/...
  • Local preview server: /advanced-agentic-dev-patterns/card-fragment/zh/concepts/a2a-protocol → 200; the old prefix-less path → 404 (confirms the original symptom)
  • Deployed to fork's Pages (https://nanxingw.github.io/advanced-agentic-dev-patterns/zh/wiki) — Draw button now opens the card fragment instead of the GitHub 404 page

🤖 Generated with Claude Code

The Knowledge Atlas Draw button opens a modal that loads the picked
card via an <iframe>. The src was hardcoded as
`/card-fragment/<lang>/<kind>/<slug>`, missing the Astro `base` prefix.

Locally (base="") it worked. On GitHub Pages, where the site lives
under `/advanced-agentic-dev-patterns/`, the iframe requested
`/card-fragment/...` against the domain root, so Pages served its
default "There isn't a GitHub Pages site here." 404 inside the modal —
which is exactly what issue PanQiWei#14's screenshot shows.

Fix: pass BASE through `.gacha[data-base]` (mirroring the existing
`data-lang` channel for client-side script) and prepend it when
building the iframe src. Build verified: with SITE_BASE set, the
emitted HTML carries `data-base="/advanced-agentic-dev-patterns"`,
and a preview server confirms the prefixed URL returns 200 while the
old prefix-less URL still 404s.

Closes PanQiWei#14

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@PanQiWei PanQiWei merged commit 71e8692 into PanQiWei:main Apr 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

抽卡功能报404的bug

2 participants