Repository navigation
chore(web): upgrade docs site to astro 7 - #59845
rekram1-node wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
The upgrade looks sound. I ran bun install and bun run build in packages/web on the PR head and both succeed. The build writes the new dist/server + dist/client layout that SST reads, and config.json and tui.json end up in dist/client/. I also checked that the share page's hide-first-panel rule no longer appears in any shared _astro stylesheet, and that the theme's header links still render with prerenderEnvironment: "node". I didn't test an actual deploy; as you note, the dev deploy after merge is the real check.
Public API: unchanged. This is a docs-site build change, and the SST_WRANGLER_PATH it reads is set by SST's own Astro component.
One small point inline: the Hero.astro check can never match the home page now.
| import Lander from './Lander.astro'; | ||
|
|
||
| const { slug } = Astro.locals.starlightRoute.entry; | ||
| const { id } = Astro.locals.starlightRoute.entry; |
There was a problem hiding this comment.
entry.id is the collection ID, so the root page's ID is "index", never "" ([...slug].md.ts also looks up the root as "index"). If a page ever sets hero, the Lander won't render. Starlight's route slug is Astro.locals.starlightRoute.id, which is "" for the root, so that's probably the right replacement for the old slug. Nothing uses hero today, so the output doesn't change.
There was a problem hiding this comment.
Starlight normalizes this one: Astro.locals.starlightRoute.entry goes through normalizeCollectionEntry(), which maps an ID of "index" to "" (utils/routing/index.ts, normalizeIndexSlug). So for the root page entry.id is "", the same as the old entry.slug. [...slug].md.ts sees "index" because it calls getCollection directly and skips that step. entry.id also keeps the old behavior for localized roots (ja/index.mdx gives "ja") and for fallback pages, where route.id would be the localized slug. So I left it as is.
I moved the docs site (
packages/web) from Astro 5 to Astro 7, matchingpackages/postsandservices/www.Versions
astro@astrojs/starlight@astrojs/cloudflare@astrojs/solid-js@astrojs/markdown-remark@astrojs/checkStarlight stays on 0.41.11 on purpose. 0.42 makes
Tabs,StepsandFileTreeparse HTML with Sätteri at render time, and Sätteri can't run in workerd, so the server bundle fails to build. The Starlight maintainers recommend staying on 0.41.11 for Cloudflare until that's fixed: withastro/starlight#4194Config and code changes
markdown.rehypePlugins→markdown.processor: unified({ rehypePlugins }). Astro 7 uses Sätteri for Markdown by default, so remark/rehype plugins need the unified processor.content.config.tsimportszfromastro/zod; Astro 6 deprecatedzfromastro:content.configPath: process.env.SST_WRANGLER_PATH. SST'scloudflare.Astrocomponent checks for this line on Astro 6+ and won't deploy without it. Duringsst deployit points the build at the wrangler config SST generates, withnodejs_compatand the worker vars.prerenderEnvironment: "node". Adapter 13+ prerenders in workerd by default. The theme hands itsheaderLinksoption to its components throughglobalThis, which only works if pages prerender in the same Node process as the config. Without this, the header links disappear from every page. This also matches how Astro 5 prerendered.config.jsonandtui.jsonare now written todist/client/, the new assets directory, so they're still served at/config.jsonand/tui.json.s/[id].astro: the share page's page-wideis:globalstyles ended up in a stylesheet shared with 91 docs pages (all the ones that useTabs). The rule that hides the first content panel then removed the page title on those pages. I moved the styles into an inline<style is:inline>inside the page. I also reset the top margin that Starlight 0.36+ adds before client islands, so the share page stays where it was.Hero.astrousesentry.idinstead ofentry.slug, which is no longer on Starlight's entry type. No page setshero, so this doesn't change any output..wrangler/is gitignored; the adapter now creates it during builds.Theme
toolbeam-docs-theme@0.4.8is the latest release. Its peer ranges are stillastro ^5.7.13and@astrojs/starlight ^0.34.3. Its code works unchanged with Astro 7 and Starlight 0.41: it uses theconfig:setuphook,astro/zodand Starlight's virtual modules, and its mobile menu CSS still matches 0.41's markup. Because the peers don't match, bun recorded a nested Astro 5 and Starlight 0.34 tree for it inbun.lock. I addedastroand@astrojs/starlightto the root catalog and tooverrides(the same pattern assolid-js), so the theme's peers resolve to the workspace versions. posts and www now useastro: "catalog:"too, so the version lives in one place. A patch wouldn't help: bun resolves peers from the registry manifest, not from patched files.Deploy
The docs still deploy via
sst.cloudflare.x.Astroininfra/app.ts, and I didn't change anything there. Adapter 14 producesdist/server/entry.mjs,dist/server/wrangler.jsonanddist/client/instead ofdist/_worker.jsanddist. SST 4.13.1 already detects this layout: it readsdist/server/wrangler.jsonand deploysentry.mjswithdist/clientas the assets._routes.jsonis gone. SST ignored it before because Workers static assets don't use it, so routing doesn't change. The first real check is thedevdeploy after merge.Verification
bun run buildinpackages/websucceeds, both plain and withSST_WRANGLER_PATHpointing at a wrangler config shaped like the one SST writes (nodejs_compat, vars). Warnings match the old build apart from one new info-level Starlight warning (Entry docs → 404 was not found), and the 404 page renders the same.dist/server/entry.mjswith esbuild using the conditions SST uses for workers (workerd,worker,browser). It resolves everything; the only imports left unbundled are node built-ins andcloudflare:workers._routes.json(dropped),_headersand.assetsignore(added by the adapter).x-defaulthreflang link, tab IDs liketab-0-1, and one French heading ID that now keeps a trailing hyphen. Nothing links to that heading.wrangler devand the new one withastro preview, and compared them with Playwright screenshots at 1440px and 390px:/docs/config.md,/config.jsonand/tui.jsonreturn 200 on the preview;/docs/s/<id>renders through the worker.astro devserves/docs/,/docs/config/,/docs/ja/and/docs/config.md.astro check: 17 errors before, 17 after. The newHero.astrotype error is fixed; the rest already existed.bun install --frozen-lockfilepasses. In the lockfile, the only packages added or removed belong to the docs site's dependency tree. The other changed lines are bun moving shared packages up or down a level after Astro 5's dependencies left; each consumer resolves the same version as before.bun run buildinpackages/postsstill passes withastro: "catalog:".