fix(i18n): drop doubled locale prefix in Governance TOC links#57
fix(i18n): drop doubled locale prefix in Governance TOC links#57JohnRDOrazio merged 1 commit intomainfrom
Conversation
GovernanceTOC was passing Polylang's locale-prefixed `uri` directly to next-intl's `<Link>`, which prepended the locale again — Italian links became `/it/it/governance-2/governanza-del-progetto`. Change `getChildPages` to derive the EN canonical slug from `translations` (querying WPGraphQL+Polylang once) and pass it through to GovernanceTOC, which now composes the URL from the parent's path plus the EN slug. next-intl adds the locale prefix exactly once, matching what Header.tsx already does. URLs continue to use EN slugs site-wide; consuming the locale's own translated slugs is tracked separately in #55. Drive-by: drop unused `page` parameter on `renderBlog` to clear a TS6133 LSP warning. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughRemoves reliance on Polylang's Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 12 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Closes #53.
Summary
GovernanceTOCwas passing Polylang's already-locale-prefixeduridirectly to next-intl's<Link>, which then prepended the locale again — Italian links becamehttps://catholicdigitalcommons.org/it/it/governance-2/governanza-del-progetto.This switches
getChildPagesto derive the EN canonical slug from each child'stranslationsfield (one extra GraphQL field per child, no extra round-trip) and passes it through toGovernanceTOC, which now composes the URL from the parent's path plus the EN slug. next-intl adds the locale prefix exactly once, matching the existingHeader.tsxconvention.URLs continue to use EN slugs site-wide; switching to translated slugs in URLs is the bigger refactor tracked in #55, which depends on the slug strategy decision in discussion #56.
Files changed
lib/wordpress/queries.ts—GET_CHILD_PAGESnow requeststranslations { language { code } slug }instead of the unuseduri.lib/wordpress/api.ts—WPChildPageexposesenSlug(EN canonical) instead ofuri/slug. For EN locale,enSlugis the page's own slug; otherwise it's read off the EN translation.app/[lang]/[[...slug]]/page.tsx— passes the current path asparentPathtoPageRenderer.components/sections/PageRenderer.tsx— forwardsparentPathtorenderGovernanceTOC→<GovernanceTOC />. Drops unusedpageparam fromrenderBlog(drive-by, clears a TS6133 LSP warning).components/sections/GovernanceTOC.tsx— composeshrefas\${base}/${page.enSlug}`instead of consumingpage.uri`.Test plan
/it/governance→ cards show Italian titles, link to/it/governance/<en-child-slug>(single locale prefix)./governance(EN default, no prefix) → cards link to/<en-child-slug>directly./es/governance,/fr/governance,/pt/governance,/de/governance— each shows a single locale prefix and EN child slugs.getPage's URI lookup).Out of scope
🤖 Generated with Claude Code
Summary by CodeRabbit