fix(website): correct next/previous links on release notes pages#11358
Draft
timotheeguerin wants to merge 3 commits into
Draft
fix(website): correct next/previous links on release notes pages#11358timotheeguerin wants to merge 3 commits into
timotheeguerin wants to merge 3 commits into
Conversation
Release notes pages showed wrong prev/next links: Starlight derives pagination from the autogenerated sidebar order, which sorts release notes alphabetically by slug (so typespec-1-12-0 was followed by typespec-1-2-0). Add a Starlight route middleware that, for release notes pages, orders the release notes chronologically by releaseDate: the sidebar shows newest-first while pagination points to the correct previous (older) and next (newer) release, with no next on the latest and no previous on the oldest. Fixes #10690
Contributor
|
No changes needing a change description found. |
|
You can try these changes here
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10690
Problem
At the bottom of a release notes page (e.g.
typespec-1-12-0) the next/previous links were wrong: the "previous" link pointed to the wrong version and a spurious "next" link appeared on the latest release.Root cause
Starlight derives prev/next pagination from the flattened sidebar order (
getPrevNextLinks). The release notes group usesautogenerate: { directory: "release-notes" }, which orders entries alphabetically by slug — sotypespec-1-12-0is followed bytypespec-1-2-0(1.2.0), andtypespec-1-1x-0sort beforetypespec-1-2-0.The existing
Sidebar.astrooverride only re-sorted the visual sidebar newest-first; it never touchedpagination, so the sidebar and the prev/next links disagreed.Starlight's built-in autogenerate ordering only supports
sidebar.order(ascending) + alphabetical — there is no date/descending sort. And even if there were, pagination follows the sidebar in a single direction, whereas we need the sidebar newest-first but pagination prev=older/next=newer. So custom pagination logic is required.Fix
Add a Starlight route middleware (
website/src/starlight-route-data.ts, the documented mechanism for customizing route data) that, for release notes pages:releaseDate, andpaginationchronologically — previous = older release, next = newer release, with no next on the newest and no previous on the oldest.Ordering now has a single source of truth, so the redundant sort block was removed from
Sidebar.astro.Verification
Built the site and inspected the generated HTML:
typespec-1-12-0typespec-1-11-0typespec-1-13-0typespec-1-14-0(latest)typespec-1-13-0cadl-typespec-migration(oldest)release-2022-07-08astro check: 0 errors.No changelog entry —
@typespec/websiteis a private package excluded from Chronus.