Add package catalog at /[name] route with curated version comparisons#1040
Add package catalog at /[name] route with curated version comparisons#1040
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@copilot I misspoke, I want the url to be /react, no pkg prefix. This means it needs to have some logic to work with the existing catch-all route. |
Fixed in commit 2975f59:
|
dd0eb80 to
8ba1186
Compare
|
@copilot fix the failing test |
Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
- Restore use of getVersionData() instead of manual extraction - Fix spacing in ComparisonList: remove gaps between elements - Fade package names with text-muted-foreground to emphasize versions - Extract generateCatalogMetadata() to separate file - Simplify isCatalogPage() to accept arrays directly - Clean up page.tsx by using utility functions Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
…rove key handling
…intainers and keywords display
There was a problem hiding this comment.
Pull request overview
This PR implements a new catalog page feature at the /[name] route that provides curated version comparisons for npm packages. When users visit a package name without specific versions, they see a two-column layout with package metadata and 10 suggested version comparisons (major, minor, and patch bumps).
Changes:
- Added catalog page detection and routing logic
- Implemented comparison generation algorithm with hierarchical bumping strategy (3 major, 3 minor, 4 patch comparisons)
- Created metadata generation for SEO optimization
- Built UI components for package metadata display and comparison list with visual highlighting
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/lib/utils/isCatalogPage.ts |
Validates catalog page requests and extracts package names from specs |
src/lib/utils/generateComparisons.ts |
Core logic for generating 10 curated version comparisons with backfill strategy |
src/lib/utils/generateComparisons.test.ts |
Comprehensive test suite covering comparison generation edge cases |
src/app/[...parts]/page.tsx |
Added catalog page detection and routing in main page component |
src/app/[...parts]/_page/catalog/generateCatalogMetadata.ts |
Generates SEO metadata for catalog pages |
src/app/[...parts]/_page/catalog/VersionWithHighlight.tsx |
Highlights changed semver digits in version comparisons |
src/app/[...parts]/_page/catalog/PackageMeta.tsx |
Left column displaying package information and external links |
src/app/[...parts]/_page/catalog/ComparisonList.tsx |
Right column showing suggested version comparisons with highlighting |
src/app/[...parts]/_page/catalog/CatalogPage.tsx |
Main catalog page component with data fetching and layout |
src/lib/utils/generateComparisons.ts
Outdated
There was a problem hiding this comment.
The parameter _versionMap is prefixed with an underscore indicating it's unused, but this prefix typically signals intentionally unused parameters. Since the versionMap is genuinely not used in the function, consider removing this parameter entirely from the function signature.
| _versionMap: Record<string, { time: string }>, |
There was a problem hiding this comment.
Fixed in commit 5861ec6. Removed the unused _versionMap parameter from generateComparisons() signature and updated all call sites and tests.
There was a problem hiding this comment.
Fixed in commit 5861ec6. Removed unused _versionMap parameter from generateComparisons() function signature and updated all call sites and tests.
There was a problem hiding this comment.
The package name is repeated four times in the comparison display (lines 67-69 and 77-79). Consider extracting this into a reusable component or constant to reduce duplication and improve maintainability.
There was a problem hiding this comment.
Fixed in commit 5861ec6. Created PackageNamePrefix component to extract the repeated package name display, reducing duplication from 4 occurrences to a reusable component.
There was a problem hiding this comment.
Fixed in commit 5861ec6. Extracted PackageNameAt component to eliminate duplication - package name now rendered through a reusable component instead of being repeated 4 times inline.
- Remove unused _versionMap parameter from generateComparisons() - Update all call sites and tests to not pass versionMap - Create PackageNamePrefix component to reduce duplication - Extract repeated package name display into reusable component - Improves maintainability and reduces code repetition Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
|
…play - Reset next-env.d.ts to match main branch (.next/dev/types/routes.d.ts) - Change comparison display from flex to inline span elements - Package name and version now flow as single text, preventing awkward breaks - Long package names no longer cause version numbers to appear as separate flex items Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
Fixed in commit 8556f1d:
|


Summary of Changes
Fixed critical comparison logic bug and addressed all code review comments:
Critical Fix (commit 017022c)
Comparison Logic Bug: Was comparing with LAST version instead of FIRST
18.3.1...19.2.4(wrong - 19.2.4 is not first of major 19)18.3.1...19.0.0(correct - 19.0.0 is first of major 19)Latest UI Fixes (commit [current])
next-env.d.tsto match main branchflex items-centerto inlinespanelementsBefore fix: Long package names would break, and version appeared as separate flex item
After fix: Full comparison text flows inline naturally
Bot Review Fixes (commit 5861ec6)
_versionMapparameter fromgenerateComparisons()PackageNamePrefixcomponent to reduce package name duplicationPrevious Refactoring (commit c27f223)
getVersionData()- reuses existing cached functiongenerateCatalogMetadata()to separate fileisCatalogPage()to work with arrays directlypage.tsx- more concise and maintainableAll Previous Changes
fromversion instead oftoAll 131 tests passing, build successful, linter passing.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.