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

Parse <StarlightPage /> frontmatter asynchronously #2279

Merged

Conversation

HiDeoo
Copy link
Member

@HiDeoo HiDeoo commented Sep 3, 2024

Description

This PR updates how the frontmatter data passed down to the <StarlightPage /> component is parsed. Starting with Astro 4.14.0, schemas containing collection references contains an async transform which would failed to be parsed due to our usage of Zod safeParse() instead of safeParseAsync().

I decided to create a new parseAsyncWithFriendlyErrors() instead of always parsing schemas asynchrounously as parseWithFriendlyErrors() is used in the plugin setup hook updateConfig option and I did not want to change that behavior. The new function is now only used in this specific case.

Regarding testing, I decided to not add a test as we cannot really easily have a unit test with a custom schema using extend and having an E2E test for this would require using a different Astro version. Creating a unit test simply calling parseAsyncWithFriendlyErrors() with a schema containing an async refinement or transform doesn't provide much value imo. Let me know if you think otherwise.

Altho, I used the reproduction in #2270 and tested the fix using Astro 4.13.4 and the latest version and both are now working as expected.

Copy link

changeset-bot bot commented Sep 3, 2024

🦋 Changeset detected

Latest commit: cf7fbd5

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 Sep 3, 2024
Copy link

netlify bot commented Sep 3, 2024

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit cf7fbd5
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/66d71411b20ebd0008ce0041
😎 Deploy Preview https://deploy-preview-2279--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the investigations and quick fix @HiDeoo!

@delucis delucis added the 🌟 patch Change that triggers a patch release label Sep 3, 2024
@delucis delucis merged commit 62d59e2 into withastro:main Sep 4, 2024
16 checks passed
HiDeoo added a commit to HiDeoo/starlight that referenced this pull request Sep 7, 2024
* main: (37 commits)
  [ci] format
  i18n(ko-KR): update `manual-setup.mdx` (withastro#2294)
  i18n(ko-KR): update `configuration.mdx` (withastro#2295)
  [ci] release (withastro#2292)
  Add support for SSR (withastro#1255)
  Add Markdoc preset and example (withastro#2249)
  Refactor sidebar persistence logic for better slow device performance (withastro#2242)
  [ci] format
  Add docs.ryzekit.com to showcase (withastro#2291)
  Update astro dependency to 4.15.3 across monorepo (withastro#2289)
  [ci] release (withastro#2290)
  Prevent Zod errors from crashing build (withastro#2288)
  i18n(fr): update `guides/css-and-tailwind` (withastro#2286)
  i18n(ko-KR): update `css-and-tailwind.mdx` (withastro#2284)
  Add WCAG AAA colour contrast option to theme editor (withastro#2282)
  [ci] release (withastro#2283)
  Parse `<StarlightPage />` frontmatter asynchronously (withastro#2279)
  Ensure unhandled directives are restored without any extra whitespace (withastro#2281)
  i18n(fr): update `resources/plugins` (withastro#2278)
  i18n(ko-KR): update `plugins.mdx` (withastro#2277)
  ...
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
2 participants