Skip to content

Commit 0cae3e8

Browse files
committed
feat(Sessions): セッションページのコンポーネントを作成
1 parent 7aef182 commit 0cae3e8

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
import { User, FileText } from "@lucide/astro";
3+
import Card from "../Card.astro";
4+
5+
type Props = {
6+
session_id: string;
7+
speaker_name: string;
8+
title: string;
9+
abstract: string;
10+
self_introduction?: string;
11+
image_url?: string;
12+
};
13+
14+
const { speaker_name, title, abstract, self_introduction, image_url } = Astro.props;
15+
---
16+
17+
<Card class="p-8 mb-5">
18+
<div class="flex flex-col items-center gap-6 md:flex-row md:items-start">
19+
<div class="flex-shrink-0">
20+
<span
21+
class="relative flex h-24 w-24 shrink-0 overflow-hidden rounded-full md:h-32 md:w-32"
22+
>
23+
<img
24+
class="aspect-square h-full w-full text-center object-cover"
25+
alt={speaker_name}
26+
src={image_url || 'https://via.placeholder.com/150?text=' + encodeURIComponent(speaker_name.charAt(0))}
27+
/></span
28+
>
29+
</div>
30+
<div class="flex-1 text-center md:text-left">
31+
<div class="mb-3">
32+
<h3 class="mb-2 text-2xl font-bold text-gray-900 md:text-3xl">
33+
{speaker_name}
34+
</h3>
35+
</div>
36+
<div class="mb-4">
37+
<p class="text-lg text-gray-600 italic">{title}</p>
38+
</div>
39+
<div>
40+
<div class="mb-3 flex items-center justify-center md:justify-start">
41+
<FileText class="mr-2 h-5 w-5 text-emerald-600" />
42+
<span class="font-semibold text-gray-800">概要</span>
43+
</div>
44+
<p class="leading-relaxed text-gray-700" style="white-space: pre-line;">
45+
{abstract}
46+
</p>
47+
</div>
48+
{
49+
self_introduction && (
50+
<div>
51+
<div class="mb-3 flex items-center">
52+
<User class="mr-2 h-5 w-5 text-emerald-600" />
53+
<span class="font-semibold text-gray-800">スピーカー紹介</span>
54+
</div>
55+
<p class="leading-relaxed text-gray-600">{self_introduction}</p>
56+
</div>
57+
)
58+
}
59+
</div>
60+
</div>
61+
</Card>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
import Heading from "../Heading.astro";
3+
import Session from "./Session.astro";
4+
import { getCollection } from "astro:content";
5+
import { getSessionImageUrl } from "./index";
6+
7+
const sessions = await getCollection("sessions");
8+
9+
// 各セッションに画像URLを追加
10+
const sessionsWithImages = await Promise.all(
11+
sessions.map(async (session) => ({
12+
...session,
13+
data: {
14+
...session.data,
15+
image_url: await getSessionImageUrl(session.data.session_id),
16+
},
17+
}))
18+
);
19+
---
20+
21+
<section id="sessions" class="bg-white py-10 md:py-16">
22+
<div class="container mx-auto px-4">
23+
<Heading>セッション一覧</Heading>
24+
{sessionsWithImages.sort((a, b) => a.data.start_at.getTime() - b.data.start_at.getTime()).map((session) => <Session {...session.data} />)}
25+
</div>
26+
</section>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { ImageMetadata } from 'astro';
2+
3+
const images = import.meta.glob<{ default: ImageMetadata }>(
4+
'/src/assets/sessions/*.{png,jpg}'
5+
);
6+
7+
export async function getSessionImageUrl(sessionId: string): Promise<string> {
8+
// ファイル名とsession_idのマッピング
9+
const imageFiles: Record<string, string> = {
10+
'atusy': 'atusy.jpg',
11+
'hrsh7th': 'hrsh7th.png',
12+
'kawarimidoll': 'kawarimidoll.png',
13+
'kuuote': 'kuuote.png',
14+
'Λlisue': 'lambdalisue.png',
15+
'mikoto2000': 'mikoto2000.png',
16+
'rbtnn': 'rbtnn.jpg',
17+
'satoru_kitaguchi_register': 'satorunooshie.png',
18+
'satoru_kitaguchi_dot': 'satorunooshie.png',
19+
'teppei22': 'teppei22.jpg',
20+
};
21+
22+
const fileName = imageFiles[sessionId];
23+
if (!fileName) {
24+
return '';
25+
}
26+
27+
const imagePath = `/src/assets/sessions/${fileName}`;
28+
if (images[imagePath]) {
29+
const imageModule = await images[imagePath]();
30+
return imageModule.default.src;
31+
}
32+
33+
return '';
34+
}
35+
36+

0 commit comments

Comments
 (0)