Skip to content

Conversation

@HiDeoo
Copy link
Member

@HiDeoo HiDeoo commented Nov 3, 2024

Description

This PR fixes an issue where the FS translation system (only used with some internal integrations or remark plugins at the moment) was not handling YAML files even though Astro Content Collections support YAML files.

@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2024

🦋 Changeset detected

Latest commit: 6420bc5

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 Nov 3, 2024
@netlify
Copy link

netlify bot commented Nov 3, 2024

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 6420bc5
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/6727ac464c713e0008c171f6
😎 Deploy Preview https://deploy-preview-2565--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: 100 (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.

"hast-util-to-string": "^3.0.0",
"hastscript": "^9.0.0",
"i18next": "^23.11.5",
"js-yaml": "^4.1.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

Using the same parser used in Astro.

Comment on lines +37 to +40
const data =
filePath.ext === '.json'
? JSON.parse(content)
: yaml.load(content, { filename: fileURLToPath(url) });
Copy link
Member Author

Choose a reason for hiding this comment

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

As YAML is a superset of JSON, we could technically have only used the YAML parser, although I decided against it for 2 reasons:

  • We have a test erroring when parsing an empty JSON file, which would no longer have been an error if we used the YAML parser.
  • For malformed JSON files, an YAMLException would be thrown, which I think could be confusing for users to mention YAML when they are using JSON files.

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.

The logic and tests all look perfect — thanks @HiDeoo!

Hitting this does make me a tiny bit nervous about the content loader future of all formats being available, but at least for now we can align with Astro’s built-in support 🎉

@delucis delucis added the 🌟 patch Change that triggers a patch release label Nov 4, 2024
@delucis delucis merged commit 236467b into withastro:main Nov 4, 2024
16 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Nov 4, 2024
HiDeoo added a commit to HiDeoo/starlight that referenced this pull request Nov 6, 2024
* main: (82 commits)
  i18n(ja): Update site-search.mdx (withastro#2577)
  i18n(ja): Update pages.mdx (withastro#2576)
  i18n(fr): Update `reference/plugins.mdx` from withastro#2549 (withastro#2574)
  [ci] format
  docs: update showcase-sites.astro (withastro#2562)
  Throw an error if a showcase image does not have the required dimensions (withastro#2573)
  i18n(ja): Update frontmatter.md (withastro#2566)
  Fixes import name typo in Customize icons example (withastro#2572)
  [ci] release (withastro#2570)
  Prettier ignore a malformed YAML test file (withastro#2571)
  Add YAML support to the FS translation system (withastro#2565)
  i18n(ja): Update reference/icons.mdx (withastro#2564)
  i18n(ja): Update overrides.md (withastro#2567)
  i18n(zh-cn): Update `plugins.mdx` (withastro#2568)
  i18n(ja): Update customization.mdx (withastro#2560)
  i18n(ja): Update css-and-tailwind.mdx (withastro#2559)
  i18n(ru): update `icons.mdx` and `overrides.md` (withastro#2558)
  i18n(ru): update `i18n.mdx` and `overriding-components.mdx` (withastro#2557)
  i18n(ko-KR): update `plugins.mdx` (withastro#2556)
  i18n(ru): update `plugins.mdx` (withastro#2555)
  ...
Yoxnear pushed a commit to Yoxnear/starlight-custom that referenced this pull request Jul 23, 2025
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.

2 participants