Migrate developer hub to /docs basePath for metaplex.com/docs#448
Migrate developer hub to /docs basePath for metaplex.com/docs#448tonyboylehub merged 3 commits intomainfrom
Conversation
Add Next.js basePath: '/docs' so the site can be served at metaplex.com/docs instead of developers.metaplex.com. - Add basePath config to next.config.js - Fix middleware redirects to use request.nextUrl.clone() instead of new URL() which doesn't include basePath - Add '/' to middleware matcher for basePath root path compatibility - Fix root path rewrite trailing slash issue - Prefix static asset paths in _document.jsx, Header, Footer, MobileNavigation with /docs - Update SITE_URL and domain references in SEOHead, sitemap, OG image generation, llms-txt script, OfficialLinks, robots.txt - Add custom Markdoc link node (MarkdocLink.jsx) to render internal links via Next.js Link for automatic basePath handling - Fix locale detection to strip /docs from browser pathname - Update OG image to use self-referencing host URL for logo fetch - Replace all hardcoded developers.metaplex.com URLs in 64 markdown files across all locales
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughThis PR migrates the Developer Hub from developers.metaplex.com to metaplex.com/docs by adding Next.js basePath (/docs), updating asset and URL references across the app and markdown, making middleware redirects basePath-aware, and adding a custom Markdoc link node/component for correct internal/external link rendering. Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant Middleware
participant Router
participant MarkdocRenderer
participant NextLink
Browser->>Middleware: Request /docs/... or /docs
Middleware->>Middleware: clone URL, apply redirectTo(path)
Middleware-->>Browser: Redirect (basePath-aware)
Browser->>Router: Navigate to page path (client)
Router->>MarkdocRenderer: Render content with Markdoc links
MarkdocRenderer->>MarkdocRenderer: Resolve markdoc link node
alt internal link (starts with / or #)
MarkdocRenderer->>NextLink: Render Next.js Link (auto-prefix /docs)
NextLink-->>Browser: handle client navigation
else external link
MarkdocRenderer-->>Browser: Render <a href="..."> (external)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Resolve merge conflicts from main branch updates. Take main's relative internal links (compatible with MarkdocLink basePath handling). Fix remaining developers.metaplex.com references with correct locale prefixes for ja/ko/zh pages.
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/middleware.js (1)
310-314:⚠️ Potential issue | 🟠 MajorUse
redirectTo(request, ...)for the remaining/guidesredirects to avoid basePath leaks.Lines 313 and 337 use
new URL(newPath, request.url), which does not include basePath in the redirect URL. The codebase has aredirectTo()helper (defined at line 250) that properly handles basePath withrequest.nextUrl.clone(). Update both lines to useredirectTo(request, newPath)for consistency and to fix basePath-aware deployments.Suggested patch
@@ if (pathname === '/guides' || pathname.startsWith('/guides/')) { const newPath = pathname.replace('/guides', '/solana') - return NextResponse.redirect(new URL(newPath, request.url), 308) + return redirectTo(request, newPath) } @@ if (pathname === `/${lang}/guides` || pathname.startsWith(`/${lang}/guides/`)) { const newPath = pathname.replace(`/${lang}/guides`, `/${lang}/solana`) - return NextResponse.redirect(new URL(newPath, request.url), 308) + return redirectTo(request, newPath) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/middleware.js` around lines 310 - 314, The redirect for /guides currently builds the URL with new URL(newPath, request.url) and calls NextResponse.redirect, which leaks basePath; replace that call with the basePath-aware helper by invoking redirectTo(request, newPath) instead. Locate the /guides redirect block (the code that computes newPath from pathname) and change NextResponse.redirect(new URL(newPath, request.url), 308) to redirectTo(request, newPath); do the same for the other /guides redirect occurrence that uses new URL(...) so both redirects use redirectTo(request, newPath) (the helper defined earlier).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@public/llms.txt`:
- Around line 54-60: Replace the hardcoded "Documentation reflects current best
practices as of 2025." string in the "Documentation Status" block (the line
containing that exact phrase) with a timeless or metadata-driven statement;
either remove the year to read "Documentation reflects current best practices."
or substitute a generated date token/variable (e.g., build or last-updated
metadata) so the text stays accurate without manual updates.
In `@scripts/generate-llms-txt.mjs`:
- Around line 205-211: The links block hardcodes the metaplex base URL
repeatedly; update each link to use the existing SITE_URL constant (e.g.,
replace 'https://metaplex.com/docs/...' with `${SITE_URL}/docs/...` or SITE_URL
+ '/docs/...') so the canonical base can be changed in one place; ensure you
preserve the path segments (docs, smart-contracts, etc.) and any trailing
slashes when updating the array of strings in scripts/generate-llms-txt.mjs.
In `@src/components/Footer.jsx`:
- Line 20: Update the broken static asset paths that include an erroneous
"/docs/" prefix: in Footer.jsx change the image src value
"src=\"/docs/metaplex-logo-white.png\"" back to "/metaplex-logo-white.png", and
make the identical correction wherever the logo path is used (Header.jsx,
MobileNavigation.jsx, and _document.jsx) so all references point to the file in
public/metaplex-logo-white.png; ensure you update the JSX/HTML src/href
attributes in the components (Footer component, Header component,
MobileNavigation component and the custom Document) rather than adding or
relying on an assetPrefix.
In `@src/components/MarkdocLink.jsx`:
- Around line 13-18: The comment in the MarkdocLink component says "External
links open in new tab" but the <a> rendered by MarkdocLink (props: href,
children) doesn't set target or rel; update MarkdocLink to detect external URLs
(e.g., href startsWith "http://" or "https://" or a helper isExternalLink) and
for those links add target="_blank" and rel="noopener noreferrer"; if you prefer
not to change behavior, instead remove or update that comment to match current
implementation. Ensure the change is made inside the MarkdocLink component (use
the existing href prop) so only external links get the new attributes.
In `@src/pages/_document.jsx`:
- Around line 36-54: The favicon/manifest link tags in src/pages/_document.jsx
currently use "/docs/..." paths which will 404 because the assets live at the
public/ root; update the hrefs in the <link> tags inside the custom Document
(MyDocument / the Head block) to point to the root asset paths (e.g.
"/apple-touch-icon.png", "/favicon-32x32.png", "/favicon-16x16.png",
"/site.webmanifest", "/safari-pinned-tab.svg") or derive them from your runtime
assetPrefix if you intentionally support a basePath; ensure all five link href
values are changed consistently.
---
Outside diff comments:
In `@src/middleware.js`:
- Around line 310-314: The redirect for /guides currently builds the URL with
new URL(newPath, request.url) and calls NextResponse.redirect, which leaks
basePath; replace that call with the basePath-aware helper by invoking
redirectTo(request, newPath) instead. Locate the /guides redirect block (the
code that computes newPath from pathname) and change NextResponse.redirect(new
URL(newPath, request.url), 308) to redirectTo(request, newPath); do the same for
the other /guides redirect occurrence that uses new URL(...) so both redirects
use redirectTo(request, newPath) (the helper defined earlier).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 13d6c543-e95e-42f3-a1c4-520efa83aadf
📒 Files selected for processing (28)
markdoc/nodes.jsmigration-summary.mdnext.config.jspublic/llms.txtpublic/robots.txtscripts/generate-llms-txt.mjssrc/components/Footer.jsxsrc/components/Header.jsxsrc/components/MarkdocLink.jsxsrc/components/MobileNavigation.jsxsrc/components/OfficialLinks.jsxsrc/components/SEOHead.jsxsrc/contexts/LocaleContext.jssrc/middleware.jssrc/pages/_document.jsxsrc/pages/api/og.jsxsrc/pages/en/dev-tools/cli/index.mdsrc/pages/en/dev-tools/cli/installation.mdsrc/pages/ja/dev-tools/cli/index.mdsrc/pages/ja/dev-tools/cli/installation.mdsrc/pages/ja/smart-contracts/inscription/getting-started/js.mdsrc/pages/ko/dev-tools/cli/index.mdsrc/pages/ko/dev-tools/cli/installation.mdsrc/pages/ko/smart-contracts/inscription/getting-started/js.mdsrc/pages/sitemap.xml.jssrc/pages/zh/dev-tools/cli/index.mdsrc/pages/zh/dev-tools/cli/installation.mdsrc/pages/zh/smart-contracts/inscription/getting-started/js.md
Add Next.js basePath: '/docs' so the site can be served at metaplex.com/docs instead of developers.metaplex.com.