Skip to content

refactor: レイアウト整理・型共通化・メタデータおよびパフォーマンス改善 - #387

Open
tanahiro2010 wants to merge 37 commits into
gakuseiBOT:mainfrom
tanahiro2010:main
Open

refactor: レイアウト整理・型共通化・メタデータおよびパフォーマンス改善#387
tanahiro2010 wants to merge 37 commits into
gakuseiBOT:mainfrom
tanahiro2010:main

Conversation

@tanahiro2010

@tanahiro2010 tanahiro2010 commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

このプルリクエストでは、コンポーネントのモジュール化、コードの一貫性向上、保守性の改善を目的としたリファクタリングおよび改善を行いました。
主な変更点として、型の共通化、レイアウトコンポーネントの整理、メタデータ処理の強化、Reactコンポーネントの最適化などがあります。


■ コンポーネントのモジュール化と再利用性の向上

  • src/components/layout/footer.tsx に新たに Footer コンポーネントを作成し、RootLayout 内のインライン実装を置き換え
  • Header コンポーネントを src/components/layout/header.tsx に移動し、構造を明確化
    → レイアウト関連コンポーネントを集約し、責務を整理

■ 型の共通化とpropsの一貫性向上

  • MemberData 型および MemberRolesrc/type/member.ts に定義し、BioCard やメンバーページで共通利用
    → 型の重複を解消し、保守性と型安全性を向上

■ メタデータおよびSEOの改善

  • 動的ページにおいて、コンテンツに応じたタイトル・説明・Open Graph情報を生成するよう generateMetadata を改善
  • announce/[slug] および updates/[slug] における Open Graph URL の不整合を修正
  • src/app/layout.tsx にグローバルな metadata と viewport 設定を追加し、SEOおよびレスポンシブ対応を強化

■ React / Next.js ベストプラクティスへの対応

  • 不要な React のimportを削除し、最新のNext.js / React仕様に準拠
  • BioCard におけるpropsの展開や key={member.name} の利用など、レンダリング効率と型安全性を改善
  • slideshow.tsx にて useMemo を用いた設定の最適化を行い、パフォーマンスと可読性を向上
  • UpdateTitle.tsx にて useCallback を使用し、コールバック関数の最適化を実施

■ 軽微なコードクリーンアップ

  • 未使用のimportやpropsを削除し、複数コンポーネントのコードを簡潔化
  • 可読性と保守性を意識した細かな整理を実施

これらの変更により、コード構造の整理、保守性の向上、そしてアプリケーション全体のパフォーマンス改善を実現しています。

Copilot AI review requested due to automatic review settings March 28, 2026 13:14
@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

共通型 MemberRole/MemberData を追加し、メンバー関連コンポーネントとページでその型を適用。BioCard の props を MemberData に統一しページ側でスプレッド渡しと key を member.name に変更。複数ページの未使用 import 削除、OG URL と updates ページの metadata/props 型を明示化。

Changes

Cohort / File(s) Summary
型定義の新規追加
src/type/member.ts
MemberRole("Owner" | "Engineer" | "Adviser" | "Moderator" | "Creator")と MemberData インターフェースを追加。
BioCard とメンバーページの型統一
src/components/bioCard.tsx, src/app/member/page.tsx
ローカルの型を削除し @/type/memberMemberData を採用。BioCard の props 型を MemberData に変更し、page.tsxmember をスプレッド渡し、key を member.name に変更。
未使用 import 削除
src/app/announce/page.tsx, src/app/howto/page.tsx, src/app/sponsor/page.tsx, src/app/member/page.tsx, src/components/bioCard.tsx, src/components/hamburger.tsx
未使用の React または不要な next/image インポートを削除。
announce スラグの OG URL 修正
src/app/announce/[slug]/page.tsx
generateMetadata の Open Graph urlhttps://gakuseibot.com/announce/${slug} に変更。
updates 詳細ページの型明示化と metadata 追加
src/app/updates/[slug]/page.tsx
UpdateDetailPageProps 型エイリアスを追加し、generateMetadata を導入。デフォルトエクスポートの引数を型エイリアスに置換。
Button の forwardRef 引数未使用化
src/components/button.tsx
forwardRef コールバックで受け取る ref_ に変更(内部で未使用扱い)。
レイアウトに Next.js メタデータ導入
src/app/layout.tsx
Metadata/Viewport を用いて export const metadata: Metadataexport const viewport: Viewport を追加し、既存の ベースの viewport 注入を除去。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed プルリクエストのタイトルは日本語で記述されており、レイアウト整理・型共通化・メタデータおよびパフォーマンス改善という複数の変更内容を網羅しています。提供されたファイル変更サマリーを確認すると、型の共通化(MemberData型の作成と利用)、メタデータの改善(layoutの更新)、未使用インポートの削除などが含まれており、タイトルは実際の主な変更内容と関連しています。
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/components/bioCard.tsx (1)

26-29: avatar が未定義の場合のフォールバックを検討してください。

avatar はオプショナルですが、undefined の場合に Avatar コンポーネントがどのように表示されるか確認が必要です。MUI Joy の Avatar はデフォルトでプレースホルダーを表示しますが、明示的なフォールバック(例:イニシャル表示)を追加することでUXが向上する可能性があります。

💡 フォールバック例
         <Avatar
           src={avatar}
           sx={{ '--Avatar-size': '4rem' }}
-        />
+        >
+          {!avatar && name?.charAt(0).toUpperCase()}
+        </Avatar>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/bioCard.tsx` around lines 26 - 29, The Avatar is rendered with
src={avatar} but avatar is optional; add an explicit fallback so when avatar is
undefined the Avatar shows a meaningful alternative (e.g., initials or an icon).
Update the BioCard component to compute a fallback (derive initials from user
name or provide a default icon string) and pass it into the Avatar via children
or replace src when avatar is falsy; modify the Avatar usage in bioCard.tsx (the
Avatar component and avatar prop) to conditionally render the fallback content
and keep the existing sx styling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/components/bioCard.tsx`:
- Around line 26-29: The Avatar is rendered with src={avatar} but avatar is
optional; add an explicit fallback so when avatar is undefined the Avatar shows
a meaningful alternative (e.g., initials or an icon). Update the BioCard
component to compute a fallback (derive initials from user name or provide a
default icon string) and pass it into the Avatar via children or replace src
when avatar is falsy; modify the Avatar usage in bioCard.tsx (the Avatar
component and avatar prop) to conditionally render the fallback content and keep
the existing sx styling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7f92f5bc-e08f-4dc8-84ec-eb6c4e5623d6

📥 Commits

Reviewing files that changed from the base of the PR and between 9fc7739 and 40ef3aa.

📒 Files selected for processing (3)
  • src/app/member/page.tsx
  • src/components/bioCard.tsx
  • src/type/member.ts

This comment was marked as resolved.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/updates/`[slug]/page.tsx:
- Around line 16-23: generateMetadata currently assumes updates.find(...)
returns a value and produces "undefined - undefined" when not found; update the
function (generateMetadata) to check the result of updates.find(...) (variable
update) and call notFound() from next/navigation when update is falsy, mirroring
the main page behavior, and ensure notFound is imported if not already present;
alternatively provide a safe fallback title only if you intentionally want
metadata without 404, but the preferred fix is to call notFound() when update is
undefined.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6da00ce9-c03a-4998-9571-65410a518f6f

📥 Commits

Reviewing files that changed from the base of the PR and between 40ef3aa and 51b3e5f.

📒 Files selected for processing (7)
  • src/app/announce/[slug]/page.tsx
  • src/app/announce/page.tsx
  • src/app/howto/page.tsx
  • src/app/member/page.tsx
  • src/app/sponsor/page.tsx
  • src/app/updates/[slug]/page.tsx
  • src/type/member.ts
💤 Files with no reviewable changes (3)
  • src/app/howto/page.tsx
  • src/app/sponsor/page.tsx
  • src/app/announce/page.tsx
✅ Files skipped from review due to trivial changes (2)
  • src/app/announce/[slug]/page.tsx
  • src/type/member.ts

Comment on lines +16 to +23
export async function generateMetadata(props: UpdateDetailPageProps) {
const { slug } = await props.params;
const update = updates.find((u) => u.slug === slug);

return {
title: `${update?.title} - ${update?.date}`,
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

update が見つからない場合のエラーハンドリングが欠けています。

slug に一致する更新情報が存在しない場合、updateundefined となり、タイトルが "undefined - undefined" になります。メインページコンポーネント(29行目)では notFound() を呼び出していますが、generateMetadata では同様の処理がありません。

🛠️ 修正案
 export async function generateMetadata(props: UpdateDetailPageProps) {
   const { slug } = await props.params;
   const update = updates.find((u) => u.slug === slug);
 
+  if (!update) {
+    return {
+      title: '更新情報が見つかりません',
+    };
+  }
+
   return {
-    title: `${update?.title} - ${update?.date}`,
+    title: `${update.title} - ${update.date}`,
   }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/updates/`[slug]/page.tsx around lines 16 - 23, generateMetadata
currently assumes updates.find(...) returns a value and produces "undefined -
undefined" when not found; update the function (generateMetadata) to check the
result of updates.find(...) (variable update) and call notFound() from
next/navigation when update is falsy, mirroring the main page behavior, and
ensure notFound is imported if not already present; alternatively provide a safe
fallback title only if you intentionally want metadata without 404, but the
preferred fix is to call notFound() when update is undefined.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/button.tsx`:
- Line 28: The Button component is discarding the forwarded ref by naming the
second forwardRef parameter "_" which prevents external refs from reaching the
DOM; update the forwardRef callback signature to accept the ref (e.g., (props,
ref) => ...) and pass it into the rendered element (attach ref to the <button>
element), ensuring the generic HTMLButtonElement ref type from
forwardRef<HTMLButtonElement, Props<AS>> is preserved so methods like focus()
work.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 676a7e5d-63ea-4f65-a8a2-730095d0a514

📥 Commits

Reviewing files that changed from the base of the PR and between 51b3e5f and dc8412d.

📒 Files selected for processing (2)
  • src/components/button.tsx
  • src/components/hamburger.tsx
💤 Files with no reviewable changes (1)
  • src/components/hamburger.tsx

Comment thread src/components/button.tsx Outdated
@tanahiro2010 tanahiro2010 changed the title メンバーの役割を整理し、BioCardコンポーネントの構造を簡素化する refactor: 型安全性・レイアウト構造・メタデータ処理の改善 Mar 29, 2026
@tanahiro2010 tanahiro2010 changed the title refactor: 型安全性・レイアウト構造・メタデータ処理の改善 refactor: レイアウト整理・型共通化・メタデータおよびパフォーマンス改善 Mar 29, 2026
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Comment thread src/app/updates/[slug]/page.tsx
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.

3 participants