Skip to content

feat: add support for build.format configuration#135

Merged
HiDeoo merged 4 commits intoHiDeoo:mainfrom
nonoakij:feat/support-build-format-file
Mar 10, 2026
Merged

feat: add support for build.format configuration#135
HiDeoo merged 4 commits intoHiDeoo:mainfrom
nonoakij:feat/support-build-format-file

Conversation

@nonoakij
Copy link
Contributor

@nonoakij nonoakij commented Mar 6, 2026

Describe the pull request

Add support for Astro's build.format configuration. When build.format is set to file, sidebar and operation links now correctly append .html suffix. Also renames getTrailingSlashTransformer to getLinkTransformer to reflect its broader responsibility.

Why

When using build.format: 'file' in Astro config, other docs pages generate links with .html extension, but pages generated by starlight-openapi plugin still used the same link format as build.format: 'directory', resulting in inconsistent link behavior across the site.

How

  • Pass build.format from Astro config through StarlightOpenAPIContext via the Vite plugin
  • Rename getTrailingSlashTransformer to getLinkTransformer and add a branch that appends .html when build.format is not directory
  • Strip .html suffix when comparing pathnames for isCurrent sidebar highlighting

Screenshots

This screenshot shows the result of running astro build and then astro preview after specifying build.format: 'file' in docs/astro.config.ts.

Screenshot-chrome

When build.format is set to file, links now correctly append .html
instead of relying solely on trailing slash behavior. Renames
getTrailingSlashTransformer to getLinkTransformer to reflect its
broader responsibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 6, 2026

@nonoakij is attempting to deploy a commit to the HiDeoo's projects Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2026

🦋 Changeset detected

Latest commit: 5a34287

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

This PR includes changesets to release 1 package
Name Type
starlight-openapi 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

@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
starlight-openapi Ready Ready Preview, Comment Mar 10, 2026 10:55am

Copy link
Owner

@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.

Thanks for your contribution 🙌

The change looks great to me. I slightly tweaked the code to make sure we use the same strategy that Starlight uses, e.g. when using preserve and adding a few helpers, but other than that, the logic is the same.

@HiDeoo HiDeoo merged commit bba6ed9 into HiDeoo:main Mar 10, 2026
4 checks passed
@github-actions github-actions bot mentioned this pull request Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants