Skip to content

Commit e1d49cf

Browse files
committed
Hide section if latestEvent is blank
1 parent 1279bfb commit e1d49cf

File tree

1 file changed

+37
-32
lines changed

1 file changed

+37
-32
lines changed

src/pages/index.astro

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ import type { Conference } from '../types/conference'
1414
1515
// 最新の3件のブログ記事を取得
1616
const latestPosts = await getPosts(3)
17+
18+
// 最新のイベント(status == 'registered')を取得
19+
const latestEvents = Conferences?.filter(
20+
(conference) => conference.status == 'registered',
21+
) || []
1722
---
1823

1924
<Layout title="CloudNative Days" description="CloudNative Days はコミュニティ、企業、技術者が一堂に会し、クラウドネイティブムーブメントを牽引することを目的としたテックカンファレンスです。" ogImage="/favicon.svg" isTopPage={true}>
@@ -33,40 +38,40 @@ const latestPosts = await getPosts(3)
3338
</p>
3439
</Hero>
3540

36-
<section class="py-24 backdrop-blur-sm">
37-
<div class="container mx-auto px-4">
38-
<h2 class="text-black relative px-4 text-4xl font-bold mb-16 text-center">
39-
最新のイベント
40-
</h2>
41-
<div class="relative">
42-
<div class="flex flex-col gap-20">
43-
{
44-
Conferences?.filter(
45-
(conference) => conference.status == 'registered',
46-
).map((conference, index) => {
47-
const url = `https://event.cloudnativedays.jp/${conference.abbr}`
48-
const eventDays = conference.conferenceDays
49-
.filter((day) => !day.internal)
50-
.map((day) => day.date)
51-
.join(',')
52-
return (
53-
<a href={url} class="block group">
54-
<Event
55-
name={conference.name}
56-
days={eventDays}
57-
img={conference.image}
58-
theme={conference.theme}
59-
about={conference.about}
60-
align={index % 2 === 0 ? 'left' : 'right'}
61-
/>
62-
</a>
63-
)
64-
})
65-
}
41+
{latestEvents.length > 0 && (
42+
<section class="py-24 backdrop-blur-sm">
43+
<div class="container mx-auto px-4">
44+
<h2 class="text-black relative px-4 text-4xl font-bold mb-16 text-center">
45+
最新のイベント
46+
</h2>
47+
<div class="relative">
48+
<div class="flex flex-col gap-20">
49+
{
50+
latestEvents.map((conference, index) => {
51+
const url = `https://event.cloudnativedays.jp/${conference.abbr}`
52+
const eventDays = conference.conferenceDays
53+
.filter((day) => !day.internal)
54+
.map((day) => day.date)
55+
.join(',')
56+
return (
57+
<a href={url} class="block group">
58+
<Event
59+
name={conference.name}
60+
days={eventDays}
61+
img={conference.image}
62+
theme={conference.theme}
63+
about={conference.about}
64+
align={index % 2 === 0 ? 'left' : 'right'}
65+
/>
66+
</a>
67+
)
68+
})
69+
}
70+
</div>
6671
</div>
6772
</div>
68-
</div>
69-
</section>
73+
</section>
74+
)}
7075

7176
<section class="py-24">
7277
<div class="container mx-auto px-4">

0 commit comments

Comments
 (0)