Skip to content

fix(deps): upgrade astro to v7 and migrate content collections - #20

Merged
h13 merged 1 commit into
mainfrom
chore/astro-7-node-24
Jul 26, 2026
Merged

fix(deps): upgrade astro to v7 and migrate content collections#20
h13 merged 1 commit into
mainfrom
chore/astro-7-node-24

Conversation

@h13

@h13 h13 commented Jul 26, 2026

Copy link
Copy Markdown
Owner

背景

Renovate が自力で処理できなかった 3 件をまとめて解決します。

PR 内容 状態
#18 astro v7 [security] renovate/artifacts 失敗
#17 @astrojs/mdx v7 renovate/artifacts 失敗
#16 node 20 → 24 lint のみ実行、docs/import は未検証

#17 / #18docs/package.json だけを書き換えて package-lock.json の再生成に失敗していました。原因は astro v6 の破壊的変更にコード修正が必要で、Renovate にはそれができないためです。

セキュリティ

#18 は Astro の define:vars を使った <script> に SSR でリクエスト由来の値を渡すと、</Script> の大文字小文字を無視したマッチでスクリプトブロックが閉じられ XSS が成立する脆弱性の修正です。優先して取り込むべき更新です。

Content Layer API への移行

astro v6 で legacy content collections が削除され、LegacyContentConfigError でビルドが落ちます。

[LegacyContentConfigError] Found legacy content config file in "src/content/config.ts".
  • src/content/config.tssrc/content.config.ts
  • type: contentloader: glob({ base, pattern })
  • entry.slugentry.id
  • await entry.render()await render(entry)

URL は変わりません。 glob loader の id は旧 slug と同じ値に解決されるため、生成物のパスは同一です(ビルド出力で確認済み)。

node 24

astro v7 の要求は Node 20.19+/22.12+/24+。#16 単体では docs.yml / import.yml が push トリガーのみで PR CI に出てこないため未検証でしたが、本 PR ではローカルで node 24 実行のビルドを通しています。

テスト計画

  • npm install でロックファイル再生成(astro 7.1.3 / @astrojs/mdx 7.0.3)
  • node v24.18.0 で npm run build 成功
  • 11 ページ生成、URL が移行前と一致することを出力で確認
    • /contracts/{employment-contract-sample,nda-sample,service-agreement-sample}/
    • /regulations/{attendance-policy,caregiver-leave-policy,expense-policy,security-policy,work-rules}-sample/
  • CI green

関連

Supersedes #16, #17, #18.

Renovate could not land astro v7 (#18, a security update) or
@astrojs/mdx v7 (#17): both only edited docs/package.json and failed the
renovate/artifacts check because regenerating package-lock.json requires
code changes that Renovate cannot make.

astro v6 removed legacy content collections, so the build fails with
LegacyContentConfigError until the Content Layer API migration is done:

- src/content/config.ts -> src/content.config.ts
- type: content -> loader: glob({ base, pattern })
- entry.slug -> entry.id
- await entry.render() -> await render(entry)

Collection ids resolve to the same values the old slugs had, so every
generated URL is unchanged (verified against the build output).

Also bumps CI node 20 -> 24 (supersedes #16). astro v7 requires Node
20.19+/22.12+/24+, and docs.yml/import.yml only run on push to main, so
that bump was never exercised by PR CI on its own.

Supersedes #16, #17 and #18.
@h13
h13 merged commit e5dc89f into main Jul 26, 2026
1 check passed
@h13
h13 deleted the chore/astro-7-node-24 branch July 26, 2026 07:23
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.

1 participant