-
Notifications
You must be signed in to change notification settings - Fork 39
様々な箇所でAstroのContent Collectionsを使う #1777
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
base: master
Are you sure you want to change the base?
Conversation
|
🚀 Deployed on https://deploy-preview-1777--utelecon.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates the codebase to use Astro's Content Collections feature with Zod schema validation, replacing the deprecated Astro.glob() API. This change provides type safety, runtime validation, and better data management for various content types including notices, events, navigation, good practices, and emergency notifications.
Key changes:
- Introduction of a centralized
src/content.config.tswith Zod schemas for all content collections - Migration from
Astro.glob()and direct YAML imports togetCollection()andgetEntry()APIs - Moved utility functions from
src/data/utils/notices.tstosrc/lib/util.tsfor better organization - Enhanced validation with warnings for notices missing bilingual titles
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
src/content.config.ts |
New centralized configuration defining all content collections with Zod schemas for emergencies, events, notices, navigation, pages, and interviews |
src/pages/good-practice/index.mdx |
Updated to use Content Collections API instead of the deleted _Loader.astro component |
src/pages/good-practice/_Loader.astro |
Deleted file - functionality moved inline to index.mdx |
src/lib/util.ts |
Added date formatting utility functions moved from the deleted notices utility file |
src/layouts/Header/Navigation.astro |
Changed from direct YAML import to getEntry() API for navigation data |
src/layouts/Footer/Navigation.astro |
Changed from direct YAML import to getEntry() API for navigation data |
src/layouts/Emergency.astro |
Updated to use Content Collections with getCollection() and render() APIs |
src/emergencies/sample.md |
Added dummy emergency entry to avoid empty collection warnings |
src/data/utils/notices.ts |
Deleted - utilities moved to src/lib/util.ts and ID generation moved to content.config.ts |
src/data/schemas/notice.d.ts |
Deleted TypeScript type definitions, replaced by Zod schema inference |
src/data/schemas/nav.d.ts |
Deleted TypeScript type definitions, replaced by Zod schema inference |
src/components/pages/rss.ts |
Updated to use getEntry() API for retrieving notices |
src/components/pages/Sitemap.astro |
Updated to use getCollection() and getEntry() APIs for pages and navigation |
src/components/pages/Notice.astro |
Updated to use getEntry() API and import utilities from new location |
src/components/pages/GoodPractice.tsx |
Added missing filter options (TeX, Mathematica, UTAS, etc.) and exported constants for use in content.config.ts |
src/components/pages/Events.astro |
Updated to use getCollection() API instead of Astro.glob() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .transform( | ||
| (v) => new RegExp(v) | ||
| ) | ||
| }) |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after closing brace in the object literal. This is inconsistent with the formatting used elsewhere in the file.
| import { select } from "hast-util-select"; | ||
| import type { Lang } from "@components/types"; | ||
|
|
||
| const { data: noticesWithId } = await getEntry("notices", "notice")! |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon at the end of the statement. This is inconsistent with the coding style used in the rest of the file where other statements have semicolons.
| const { data: noticesWithId } = await getEntry("notices", "notice")! | |
| const { data: noticesWithId } = await getEntry("notices", "notice")!; |
| ja, | ||
| en, | ||
| }[lang]; | ||
| const { data } = await getEntry("nav", lang)! |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon at the end of the statement. This is inconsistent with line 11 in Header/Navigation.astro which has a semicolon, and also inconsistent with other statements in the same file.
| const { data } = await getEntry("nav", lang)! | |
| const { data } = await getEntry("nav", lang)!; |
| (v) => new RegExp(v) | ||
| ) | ||
| }) | ||
| }) |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after closing brace in the object literal. This is inconsistent with the formatting used elsewhere in the file.
| }) | |
| } ) |
| ) | ||
| }) | ||
| ) | ||
| }) |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after closing brace in the object literal. This is inconsistent with the formatting used elsewhere in the file.
| return { ...notice, id }; | ||
| }).toReversed(); | ||
| }) | ||
| }) |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after closing brace in the object literal. This is inconsistent with the formatting used elsewhere in the file.
| tools: z.string() | ||
| }) | ||
| }) | ||
| }) |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after closing brace in the object literal. This is inconsistent with the formatting used elsewhere in the file.
| }) | |
| } ) |
| { label: "実験・実習", value: "experiment" }, | ||
| { label: "グループワーク", value: "group-work" }, | ||
| { label: "TA", value: "ta" }, | ||
| { label: "テキスト", value: "text"} |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space before closing brace in the object literal. This is inconsistent with the formatting used elsewhere in the file.
| { label: "テキスト", value: "text"} | |
| { label: "テキスト", value: "text" } |
| @@ -0,0 +1,144 @@ | |||
| import { styleText } from "node:util"; | |||
| import { defineCollection } from "astro:content"; | |||
| import { z } from "astro/zod" | |||
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon at the end of the import statement. This is inconsistent with the other import statements in the file which all end with semicolons.
| import { z } from "astro/zod" | |
| import { z } from "astro/zod"; |
| import { getISODateString } from "src/lib/util"; | ||
|
|
||
| const emergencies = defineCollection({ | ||
| loader: glob({pattern: "*.{md,mdx}", base: "./src/emergencies" }), |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after the opening brace in the object literal. This is inconsistent with formatting used elsewhere in the file and across the codebase.
概要
Astro.glob()を使っている箇所の改修も兼ねています変更対象
Astro.glob()やimport foo from "foo.yml";などの方法で取得されていたものです(Markdown / MDX、YAML)変更対象の一覧・留意点
src/emergencies/sample.md)を追加しています 805b228idを付与する処理をZodの.transform()内に移した結果、src/data/utils/notice.tsにはユーティリティ関数のみが残ったため、削除してsrc/lib/util.tsに移動しました e0cf9desrc/pages/good-practice/_Loader.astroを消してsrc/pages/good-practice/index.tsxにまとめました今後の見通し
/events)は、現在は手書きだが、お知らせページと同様にYAMLから生成できそう