Fix VitePress base path for phenotype.space#68
Conversation
Only apply repo subpath base when GITHUB_PAGES is set; default to `/` so Cloudflare subdomain builds resolve CSS from `/assets/`. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
CodeAnt AI is reviewing your PR. |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
| const explicit = process.env.DOCS_BASE ?? process.env.VITEPRESS_BASE | ||
| if (explicit) return explicit.endsWith('/') ? explicit : `${explicit}/` |
There was a problem hiding this comment.
Suggestion: The explicit base normalization only enforces a trailing slash, so values like Tokn become Tokn/ (missing leading slash), which produces invalid VitePress base paths and broken asset URLs. Normalize explicit values to include both leading and trailing / for path-style bases. [logic error]
Severity Level: Major ⚠️
⚠️ Docs builds with misconfigured DOCS_BASE produce bad asset paths.
⚠️ Any external CI setting `DOCS_BASE=Tokn` breaks docs site.
⚠️ VitePress base contract violated for non-slashed env overrides.Steps of Reproduction ✅
1. Note the explicit base handling in `docs/.vitepress/config.ts:4-6`, where
`resolveDocsBase()` reads `DOCS_BASE` or `VITEPRESS_BASE` and only normalizes by appending
a trailing `/` if missing.
2. Set an explicit base without a leading slash, e.g. run the docs build locally from
`docs/` with `DOCS_BASE=Tokn npm run docs:build` (the same script used in
`.github/workflows/ci.yml:66-68`, which uses `npm run docs:build` with `working-directory:
docs`).
3. During the build, `resolveDocsBase()` will see `explicit === 'Tokn'` and return
`'Tokn/'`, because the code only checks `explicit.endsWith('/')`.
4. VitePress `defineConfig` at `docs/.vitepress/config.ts:15-18` sets `base: docsBase` to
`'Tokn/'`, which lacks the leading `/` required for valid VitePress base paths; generated
HTML will reference asset paths like `Tokn/assets/...` instead of `/Tokn/assets/...`,
causing broken asset URLs when served from a normal site root.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** docs/.vitepress/config.ts
**Line:** 5:6
**Comment:**
*Logic Error: The explicit base normalization only enforces a trailing slash, so values like `Tokn` become `Tokn/` (missing leading slash), which produces invalid VitePress base paths and broken asset URLs. Normalize explicit values to include both leading and trailing `/` for path-style bases.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2010eaf7d0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
| if (process.env.PHENOTYPE_CUSTOM_DOMAIN === 'true') return '/' | ||
| const repo = process.env.GITHUB_REPOSITORY?.split('/')[1] | ||
| if (process.env.GITHUB_PAGES === 'true' && repo) return `/${repo}/` |
There was a problem hiding this comment.
Ensure custom-domain Pages builds skip the repo base
When the docs are built in a GitHub Pages workflow where GITHUB_PAGES=true, this branch still returns /Tokn/ unless the new PHENOTYPE_CUSTOM_DOMAIN variable is also set. I searched the repo for PHENOTYPE_CUSTOM_DOMAIN and it only appears in this config, so the documented phenotype.space custom-domain build can still emit /Tokn/assets/... and keep the broken asset URLs this commit is meant to fix unless every deploy workflow is updated separately.
Useful? React with 👍 / 👎.
User description
Summary
GITHUB_REPOSITORYon every CI build/; use/<repo>/only whenGITHUB_PAGES=trueRoot cause
HTML referenced
/Tokn/assets/...while deployed assets live at/assets/....Test plan
tokn.phenotype.spaceMade with Cursor
CodeAnt-AI Description
Fix docs asset loading for custom-domain deployments
What Changed
/as the base path on custom domains, so styles and other assets load from the site root instead of a repo subpath.Impact
✅ Working docs styling on custom domains✅ Fewer broken asset links after deploy✅ Correct GitHub Pages and custom-domain behavior💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.