Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes an edge case in custom pagination link processing #2105

Merged
merged 5 commits into from
Jul 7, 2024

Conversation

delucis
Copy link
Member

@delucis delucis commented Jul 6, 2024

Description

  • Closes Inconsistent Behavior of Links in Starlight | Frontmatter Prev and Next #1886
  • Fixes an edge case how custom prev/next links in frontmatter are handled
  • In general a custom prev/next link was applied directly to an existing link object, which produced the correct behaviour. How in the edge case where a link object wasn’t already available (e.g. pagination is disabled, or the page is first/last, so has no prev/next link), we were using a makeLink() utility designed for sidebar items that did some additional processing. This rarely caused issues, but if a user had base set, this led to inconsistencies where the base would prepended to links only in these rare edge cases.
  • This PR fixes this by ensuring links created for pagination purposes are never processed and always reflect 1:1 with the authored link in frontmatter
  • We had an old test that expected the processing, which converted x to /x, but I think that was a wrong expectation, so I updated that old test to reflect the new behaviour.

Copy link

vercel bot commented Jul 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
starlight ✅ Ready (Inspect) Visit Preview Jul 7, 2024 2:07pm
1 Skipped Deployment
Name Status Preview Updated (UTC)
starlight-i18n ⬜️ Ignored (Inspect) Jul 7, 2024 2:07pm

Copy link

changeset-bot bot commented Jul 6, 2024

🦋 Changeset detected

Latest commit: 17a7869

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label Jul 6, 2024
@astrobot-houston
Copy link
Collaborator

astrobot-houston commented Jul 6, 2024

size-limit report 📦

Path Size
/index.html 5.96 KB (0%)
/_astro/*.js 21.87 KB (0%)
/_astro/*.css 13.77 KB (0%)

@delucis delucis added the 🌟 patch Change that triggers a patch release label Jul 6, 2024
@delucis delucis changed the title Add test for pagination links with base Fixes an edge case in custom pagination link processing Jul 6, 2024
Copy link
Member

@HiDeoo HiDeoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a new function not involving formatPath() definitely seems like the proper solution to fix this issue. The updated test also makes sense to me.

Thanks for fixing this 🙌

Co-Authored-By: HiDeoo <494699+HiDeoo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 core Changes to Starlight’s main package 🌟 patch Change that triggers a patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Behavior of Links in Starlight | Frontmatter Prev and Next
3 participants